Re: No sure way to tell whether an array is mutable?
Re: No sure way to tell whether an array is mutable?
- Subject: Re: No sure way to tell whether an array is mutable?
- From: Jeff C <email@hidden>
- Date: Thu, 25 Jan 2007 22:02:29 -0500
If an object says that a return value is an NSMutableArray and you
get back an NSArray, then something is broken. You can't even claim
polymorphism, since a superclass cannot masquerade as a subclass.
I think your problem lies elsewhere.
I have been known to lose my brains and do this:
NSMutableArray *theArray=[[NSArray alloc] init];
which leads to bad things down the line, similar to what you're seeing.
On Jan 25, 2007, at 9:21 PM, Kenny Leung wrote:
Hi All.
I think I have just been burned by something sinister: an object
says that it is an NSMutableArray, but turns out to be non-mutable.
I'm wondering if anyone has run into this:
code snippet:
if ( [newChildren isKindOfClass:[NSMutableArray class]] ) {
HXDebug(@"Mutable:%@", newChildren);
}
[newChildren insertObject:entry atIndex:newIndex];
output:
DEBUG Mutable:()
*** -[NSCFArray insertObject:atIndex:]: mutating method sent to
immutable object
Thanks for any insight!
-Kenny
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
40earthlink.net
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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