开发者

How to understand which property is suitable for NSDictionary eg. retain or assign?

now i using

@property (nonatomic, retain) NSDictionary *currentAttribute;

if i use copy or assi开发者_如何学Pythongn instead of retain is it more difference in memory performance?


Declaring it copy would mean you get an entirely new NSDictionary object for use with your class. If it's quite a large dictionary this can be a performance hit; not very noticeable, but significant anyway. By retaining it, you simply give your class its own pointer to the same NSDictionary instance.

Declaring it assign puts your application at risk of crashing in case the NSDictionary is autoreleased. If it ends up in the pool and gets deallocated because the pool reduced its retain count to 0, your class won't get to access it anymore, causing a crash.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜