Groups
Groups
Sign in
Groups
Groups
iOS development
Conversations
About
Send feedback
Help
《周报》 关于property声明copy
2 views
Skip to first unread message
没、方向感
unread,
Dec 12, 2011, 6:22:31 AM
12/12/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to iOS development
@property (nonatomic,copy)中用copy声明一个属性。是因为可能存在可变的属性。如果使用retain声明该属性,若一段
外部代码改变这个属性的值,则下一次使用该属性会是改变过后的值。使用copy则能避免这一情况的发生。同时copy也和retain一样增加了计数器
的值。
没、方向感
unread,
Jan 19, 2012, 7:00:06 AM
1/19/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to iOS development
推荐做法是NSString用copy,delegate用assign(且一定要用assign,不要问为什么,只管去用就是了,以后你会明白的),
非objc数据类型,比如int,float等基本数据类型用assign(默认就是assign),而其它objc类型,比如NSArray,
NSDate用retain。
Reply all
Reply to author
Forward
0 new messages