开发者

Referencing to objects from anywhere in Cocoa

开发者 https://www.devze.com 2022-12-22 22:53 出处:网络
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? de

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号