In this code
id (^block)(void) = ^(void) {
return nil;
};
I have this error
Incompatible block pointer types initializing 'id (^__strong)(void)' with an expression of type 'void *(^)(void)'
So I have to explicitly cast nil
to id
type
id (^block)(void) = ^(void) {
return (id)nil;
};
to make compiler happy. Buy why nil
is not id
type?
And for this code
__typeof__(nil) dummy;
dummy = [NSObject new];
Implicit conversion of Objective-C pointer type 'NSObject *' to C pointer type 'typeof (((void *)0))' (aka 'void *') requires a bridged cast
which is saying nil
is (void *)0
, but isn't just same as NULL
? I though nil
should be (id)0
and Nil
should be (Class)0
?
I am using Xcode 4.6.2
Compiler: Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
#import
statements:#undef nil #undef Nil #define nil ((id)(NULL)) #define Nil ((Class)(NULL))
– JDS