开发者

Difference between property attributes in objective-c

开发者 https://www.devze.com 2023-01-17 07:05 出处:网络
When to use attributes and What is the pur开发者_C百科pose of each attribute? Some attributes: readonly - use if you don\'t want a setter

When to use attributes and What is the pur开发者_C百科pose of each attribute?


Some attributes:

readonly - use if you don't want a setter

retain - use if you want values assigned to your property to be retained

copy - use if you want values assigned to your property to be copied.

assign - use if you want new values to be assigned with no retain or copy.

nonatomic - use to disable the mechanism that makes property access atomic. An atomic property is guaranteed to give you a pointer to a real object that still exists or nil. In a multithreaded environment, a nonatomic property could give you an object that has already been deallocated.

0

精彩评论

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