Referencing to objects from anywhere in Cocoa
What's the best way to 开发者_StackOverflow社区reference to a dynamically allocated object (particularly interface elements) so I can access them from everywhere in the current class? @synthesize? declaring the object in the interface section? anything else?
This is the very definition of an instance variable, which — as you've noted — is what you get when you declare the object in the interface section.
@synthesize
gives you syntactic sugar for correctly creating accessors, but that's another layer on top. It can do the instance variable creation for you in some cases, but that's another topic entirely.
精彩评论