• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSCopying vs NSMutableCopying for custom object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSCopying vs NSMutableCopying for custom object
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: NSMutableCharacterSet bug in Mavericks?
  • Next by Date: Re: NSCopying vs NSMutableCopying for custom object
  • Previous by thread: Re: NSMutableCharacterSet bug in Mavericks?
  • Next by thread: Re: NSCopying vs NSMutableCopying for custom object
  • Index(es):
    • Date
    • Thread