• 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
NSMutableArray is immutable when unarchived
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSMutableArray is immutable when unarchived


  • Subject: NSMutableArray is immutable when unarchived
  • From: nick briggs <email@hidden>
  • Date: Fri, 15 Jul 2005 11:02:13 +0100

Hi

I have a NSMutableArray which I routinely add objects to. This works fine until I encode / decode the array with NSCoder, as shown below.

The problem is when I now try to add an object with:

 [_triggers addObject:trigger];

I get he error:

[NSCFArray addObject:]: mutating method sent to immutable object



What's up?


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



NSMutableArray  *_triggers;



- (id)initWithObject:(id)anObject
{
    if(self = [super init])
    {
        ...
        _triggers = [[NSMutableArray array]retain];
        ...
    }
    return self;
}



- (id)initWithCoder:(NSCoder *)aDecoder
{
    ...
    _triggers   = [[aDecoder decodeObjectForKey:kTriggers]retain];
    ...
    return self;
}


- (void)encodeWithCoder:(NSCoder *)aCoder { ... [aCoder encodeObject:_triggers forKey:kTriggers]; ... }


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Cheers

Nick






_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: NSMutableArray is immutable when unarchived
      • From: SA Dev <email@hidden>
  • Prev by Date: Re: Is NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: this slow?
  • Next by Date: Re: Is NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext: this slow?
  • Previous by thread: CoreData & Spotlight
  • Next by thread: Re: NSMutableArray is immutable when unarchived
  • Index(es):
    • Date
    • Thread