Re: Inserting an (int) into an NSMutableArray
Re: Inserting an (int) into an NSMutableArray
- Subject: Re: Inserting an (int) into an NSMutableArray
- From: Todd de Gruyl <email@hidden>
- Date: Wed, 03 Aug 2005 15:07:24 -0400
On 8/3/05 14:32, Adam Raney wrote:
> I am showing my lack of knowledge of ObjC here, but I'm learning.
>
> I am trying to insert an int into an NSMutableArray, but getting an error.
NSArray (and NSDictionary, and their mutable counterparts) hold objects.
An int is not an object. In order to insert an int (or any other
primitive type) into an NSMutable array, you need to put it into an
object that can hold the value, in this case it would be an NSNumber
> My int is an instance variable of my controller class. I am trying to
> add the int to an instance variable NSMutableArray of another class
> (already properly instantiated) through this process
>
> [myObject addItemToArray: myInt];
you can use this instead here:
[myObject addItemToArray: [NSNumber numberWithInt: myInt]];
HTH,
--
Todd de Gruyl
Web: <http://www.tdegruyl.com>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden