About Objective-c blocks, the document I am reading said:
You can't refer to
self
in Independent block objects. if you need to, you must passself
object to the block as a parameter.You can't access to properties of an object inside an Independent block using dot notation. If you need to do so, use setter and getter methods.
But I can write the following, and it runs as expected.
- (void)testing
{
self.name = @"wahaha";
void (^independentBlock)(NSString *arg) = ^(NSString *arg){
self.name = @"";
NSLog(@"%@ -- %@",arg, self.name);
};
a(@"abcd"); // abcd -- wahaha
}
So, why do the rules say dot notation cannot be used?