Re: Easy/Quick Question...
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.