• 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
Re: coding NSNumber in NSArray?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: coding NSNumber in NSArray?


  • Subject: Re: coding NSNumber in NSArray?
  • From: "Henry McGilton (Boulevardier)" <email@hidden>
  • Date: Mon, 14 Sep 2009 12:09:11 -0700


On Sep 14, 2009, at 9: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]]; [node1 setNodeTitle:@"eBay"]; [node1 setURL:@"http://www.ebay.com/";];

........etc.......

NSArray *allItems = [NSArray arrayWithObjects: node1, ..etc.... nil];

[node1 release];

You're creating an auto-released NSNumber instance, and then releasing it. At a first guess,
it's over-released . . .

// -------------------------------------------------------------------------------
- (NSArray*)mutableKeys
{
NSArray *tempKeys = [NSArray arrayWithObjects:
@"typeOfLeaf",
@"nodeTitle",
@"urlString",
nil];


return tempKeys;
}
// -------------------------------------------------------------------------------
- (id)initWithCoder:(NSCoder*)coder
{
self = [self init];
NSEnumerator *keysToDecode = [[self mutableKeys] objectEnumerator];
NSString *key;
while (key = [keysToDecode nextObject])
[self setValue:[coder decodeObjectForKey:key] forKey:key];

return self;
}


// -------------------------------------------------------------------------------
- (void)encodeWithCoder:(NSCoder*)coder
{
NSEnumerator *keysToCode = [[self mutableKeys] objectEnumerator];
NSString *key;
while (key = [keysToCode nextObject])
[coder encodeObject:[self valueForKey:key] forKey:key];
}




_______________________________________________

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

_______________________________________________

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: coding NSNumber in NSArray?
      • From: Jens Alfke <email@hidden>
References: 
 >coding NSNumber in NSArray? (From: jon <email@hidden>)

  • Prev by Date: Garbage collecting live threads
  • Next by Date: Re: coding NSNumber in NSArray?
  • Previous by thread: Re: coding NSNumber in NSArray?
  • Next by thread: Re: coding NSNumber in NSArray?
  • Index(es):
    • Date
    • Thread