Re: Array question
Re: Array question
- Subject: Re: Array question
- From: Lorenzo <email@hidden>
- Date: Mon, 18 Jul 2005 00:49:45 +0200
Hi Charilaos,
you can even create a loop to add several objects to the array, like this
NSMutableArray *productArray = [[NSMutableArray alloc] init];
int i, totObjects = 10; // for example you add 10 objects
NSString *object = nil;
for(i = 0; i < totObjects ; i++){
object = [NSString stringWithFormat:@"Pack %d", i+1];
[productArray addObject:object];
}
//remember to release the array when you don't longer need it.
[productArray release];
productArray = nil;
Best Regards
--
Lorenzo
email: email@hidden
> Message: 4
> Date: Sun, 17 Jul 2005 15:40:21 -0500
> From: Charilaos Skiadas <email@hidden>
> Subject: Re: Array question
> To: Derrick Carlin <email@hidden>
> Cc: email@hidden
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> On Jul 17, 2005, at 3:32 PM, Derrick Carlin wrote:
>
>> I've been searching on-line and was able to learn how to create an
>> array like so...
>>
>> NSMutableArray *productArray;
>> productArray = [[NSMutableArray alloc] init];
>> [productArray addObject: @"Pack 1"];
>> NSLog(@"Array description: %@ items.\n", productArray);
>
>> How can I send several items to an array at the same time:
>>
>> Like "pack1", "pack2" etc.
>>
>
> Look at :
> http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
> ObjC_classic/Classes/NSArray.html#//apple_ref/doc/uid/20000137-BABEADJJ
> Especially:
> + (id)arrayWithObjects:(id)firstObj, ...
> or
> - (id)initWithObjects:(id)firstObj, ...
> depending on what you want to do with it.
>
> NSMutableArray inherits from NSArray.
>
>> D
>>
>>
>>
>> -
>> Derrick Carlin
>
> Haris
_______________________________________________
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