tags:

views:

98

answers:

3
NSMutableArray *array = [[NSArray alloc] initWithObjects:@"Apranax Forte",
                                                         @"Actified",
                                                         @"Zostex 125 MG",
                                                         @"Zoprotec 30 MG",
                                                         @"Arveles 25 MG"];

[array insertObject:@"Ahmet" atIndex:[array count] + 1]; // Neither work
[array addObject:@"Ahmet"]

I want to append the Ahmet string to the NSMutableArray array object ... Can anyone help me ?

A: 

You need to change [NSArray alloc] to [NSMutableArray alloc]

grahamparks
tHANKs to everyone .. ı do not know if stackoverflow exists !!
+1  A: 

make sure that you terminate your array with "nil"

NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:@"Apranax Forte",     @"Actified",@"Zostex 125 MG",@"Zoprotec 30 MG",@"Arveles 25 MG", nil];
samfu_1
tHANKs to everyone .. ı do not know if stackoverflow exists !!
+6  A: 

You're not instaniating a mutable array:

[[NSMutableArray alloc] initWithObjects:@"Apranax Forte",
                                        @"Actified",
                                        @"Zostex 125 MG",
                                        @"Zoprotec 30 MG",
                                        @"Arveles 25 MG",
                                        nil];

Also don't forget to terminate the collection of objects with nil.

dannywartnaby
Sometimes focusing on only one thing much more than normal prevents seeing big picture.. thnx