Your example will not compile because the delegate is not defined. I suppose you mean "SomeNeatObject * object = appDelegate.someNeatObject;"
In this example, appDelegate is a variable whose value will be committed by the block. This is no different from any other variable.
This is unsafe because the [[UIApplication sharedApplication] delegate] always returns the same unless you change the delegate, which you probably aren't doing.
Key concepts: appDelegate is a variable that points to (or refers to) an object (or instance) of type AppDelegate . There is one such instance in an iOS application that is returned by the [[UIApplication sharedApplication]] delegate. If you create a link to appDelegate inside a block, you make a copy of the variable, not the object. So, in your code block:
SomeNeatObject *object = appDelegate.someNeatObject;
This is semantically the same as putting the following code in a block (sheets omitted):
SomeNeatObject *object = [[UIApplication sharedApplication] delegate].someNeatObject;
Referred SomeNeatObjects are one and the same.
A slightly more advanced concept: any object has an address in memory (integer, usually in hexadecimal). If two variables have the same hexadecimal value, they point to the same object. If they have different meanings, they point to different objects. In your example, appDelegate (the outer block) and appDelegate (inside the block) have the same value, therefore they point to the same object.
If you must do this:
AppDelegate * otherDelegate = [appDelegate copy];
Then you make a copy of the object pointed to by appDelegate. But do not do this, please.
Sofi Software LLC
source share