Re: coding NSNumber in NSArray?
Re: coding NSNumber in NSArray?
- Subject: Re: coding NSNumber in NSArray?
- From: jon <email@hidden>
- Date: Mon, 14 Sep 2009 10:42:40 -0600
I put this code in to retain after you said that, but there was no
change in the outcome, still the array shows everything in order,
except that the NSNumber comes out as garbage.....
I checked node1 to see if it was well defined, before and after
putting it into the array, and it is.
Jon.
//
-------------------------------------------------------------------------------
- (void)setTypeOfLeaf:(NSNumber*)flag
{
if (!typeOfLeaf || ![typeOfLeaf isEqual:flag])
{
[typeOfLeaf release];
typeOfLeaf = [flag retain];
}
}
On Sep 14, 2009, at 10:21 AM, Randall Meadows wrote:
On Sep 14, 2009, at 10:11 AM, jon wrote:
I thought i had read that NSNumber knew how to code itself in an
NSArray... is this not the case? or is this code below just set up
all wrong? and what would the proper way be to set this up?
bookMarkNode's coders are below, this object has the one
NSNumber, and two NSStrings....
when i look in the debugger at "allItems", the NSNumber is not
well defined.
thanks in advance,
Jon.
BookMarkNode *node1 = [[BookMarkNode alloc] init];
[node1 setTypeOfLeaf:[NSNumber numberWithInt:0]];
What does the code for -setTypeOfLeaf: look like? If you're not
retaining it in that method then it is getting (auto)released the
next time the autorelease pool is drained. Just because the array
will automatically retain the node object doesn't mean the NSNumber
inside that object will also be retained automatically.
_______________________________________________
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