NSCopying vs NSMutableCopying for custom object
NSCopying vs NSMutableCopying for custom object
- Subject: NSCopying vs NSMutableCopying for custom object
- From: Trygve Inda <email@hidden>
- Date: Sun, 27 Oct 2013 10:58:43 -0700
- Thread-topic: NSCopying vs NSMutableCopying for custom object
My object looks like:
@interface MyObject : NSObject <NSCoding, NSCopying>
{
MyOtherObject* library;
NSString* identifier;
NSString* name;
BOOL removed;
}
@property (nonatomic, retain) MyOtherObject* library;
@property (copy, readwrite) NSString* identifier;
@property (copy, readwrite) NSString* name;
@property (readwrite) BOOL removed;
I need to be able to make a copy and have its properties be mutable (with
standard setters).
-(id)copyWithZone:(NSZone *)zone
{
MyObject* copy = [[[self class] allocWithZone:zone] init];
[copy setLibrary:[self library]];
[copy setIdentifier:[self identifier]];
[copy setName:[self name]];
[copy setRemoved:[self removed]];
return (copy);
}
This seems to work fine. So in my case is there really no difference between
a mutable copy and an immutable copy?
Thanks,
Trygve
_______________________________________________
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