Re: NSString property: copy or retain?
Re: NSString property: copy or retain?
- Subject: Re: NSString property: copy or retain?
- From: Jean-Daniel Dupas <email@hidden>
- Date: Mon, 22 Dec 2008 23:38:48 +0100
Le 22 déc. 08 à 23:04, Debajit Adhikary a écrit :
Let's say I have a class called SomeClass with a string property name:
@interface SomeClass : NSObject{
NSString* name;
}
@property (nonatomic, retain) NSString* name;
@end
I understand that name may be assigned a NSMutableString in which
case this
will may to errant behavior.
(1) For strings in general, is it *always* a good idea to use the
"copy"
attribute instead of "retain"?
Yes
(2) Is a "copied" attribute in any way less efficient than such a
"retain-ed" attribute?
No, as the string will be retain if it is immutable (the copy
operation is optimized to return [self retain])
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden