I recently switched to ARC and got a little confused about setting the correct property value for a self-object, passing it to a block.
In my understanding, any property declared with _weak should not be set to zero in the dealloc method. And the objects themselves transferred to the block should be declared with _weak , and not __ block .
Please let me know if this understanding is correct, and I am doing it correctly in the implementation below.
(void)myApplication { self.data = [NSMutableDictionary dictionary]; __weak MyViewController *aBlockSelf = self; [self.data setValue:[MyAction customActionWithBlock:^(MyAction *iAction, NSString *iIdentifier) { AnotherViewController *aController = [[AnotherViewController alloc] initWithType:@"aType"]; aController.hasSearch = NO; aController.delegate = aBlockSelf; aController.showInventoryImage = YES; [aBlockSelf presentNavigationalModalViewController: aController]; }] forKey:@"aKey"]; }
source share