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

SOLVED: NSMutableArray is immutable when unarchived


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

Yep, my fault

I'm using a caching system which involves copying _triggers... stupidly I was using

_cache = [_triggers copy]

rather than

_cache = [_triggers mutableCopy]

Thanks





On 15 Jul 2005, at 14:00, SA Dev wrote:


I'm thinking this *is* being changed somewhere else, though. What other code touches _triggers?




On Jul 15, 2005, at 8:58 AM, nick briggs wrote:


Well yes, [NSMutableArray array] is definitely mutable, else [_triggers addObject:trigger] would fail...

... using [[NSMutableArray alloc] init] still produces the immutable error :(

Not the behavior I'd expect, easy enough to work around, but why the necessity for an ugly hack?

Nick






On 15 Jul 2005, at 13:47, SA Dev wrote:




Allow me to post a retraction ... this seems like it may not be correct according to the docs: "+array Creates and returns an empty array. This method is used by mutable subclasses of NSArray."


I'd personally still use _triggers = [[NSMutableArray alloc] init]; which will work, but I might be wrong here in your situation.

  Anybody??



On Jul 15, 2005, at 8:41 AM, SA Dev wrote:




Nick:

You're replacing your _triggers NSMutableArray with an NSArray on init. :-)

  [NSMutableArray array] returns an NSArray - immutable.

Try:

_triggers = [[NSMutableArray alloc] init];



On Jul 15, 2005, at 6:02 AM, nick briggs wrote:





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





_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40silentalcove.net


This email sent to email@hidden














_______________________________________________ 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
References: 
 >NSMutableArray is immutable when unarchived (From: nick briggs <email@hidden>)
 >Re: NSMutableArray is immutable when unarchived (From: SA Dev <email@hidden>)
 >Re: NSMutableArray is immutable when unarchived (From: SA Dev <email@hidden>)
 >Re: NSMutableArray is immutable when unarchived (From: nick briggs <email@hidden>)
 >Re: NSMutableArray is immutable when unarchived (From: SA Dev <email@hidden>)

  • Prev by Date: Re: NSMutableArray is immutable when unarchived
  • Next by Date: Re: NSMutableArray is immutable when unarchived
  • Previous by thread: Re: NSMutableArray is immutable when unarchived
  • Next by thread: Re: NSMutableArray is immutable when unarchived
  • Index(es):
    • Date
    • Thread