• 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: Easy/Quick Question...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Easy/Quick Question...


  • Subject: Re: Easy/Quick Question...
  • From: David Remahl <email@hidden>
  • Date: Fri, 13 Sep 2002 11:14:06 +0200

> Sorry about this, but I havent been able to find sufficient
> documentation to sort it out by myself...
>
> Why can I not bung an integer into an array? Something to do with the
> Format? Would NSNumber or NSValue be of help here?
>
> int i=1;
> NSMutableArray *array = [[NSMutableArray alloc] init];
> [array addObject: i];

Yes. Only objects may be added to arrays (and dictionaries and other
collection classes, for that matter). The way to solve it is to encode the
int into an NSNumber:

[array addObject:[NSNumber numberWithInt:i]];

To retreive;

int i = [[array objectAtIndex:i] intValue];

/ Rgds, David
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Easy/Quick Question... (From: ben milford <email@hidden>)

  • Prev by Date: Easy/Quick Question...
  • Next by Date: ppplib.c, ppplib.h, ppp_msg.h
  • Previous by thread: Easy/Quick Question...
  • Next by thread: contextual menu and NSTextField
  • Index(es):
    • Date
    • Thread