Reputation: 55
I have mutable string array named arrayout. It is having 3 element .Now I want to add 1 String element that array.But when I try to add,it is taking null value....Cant get what to do...Please help...
My code is :
NSString *ds1 = @"--";
[arrayout arrayByAddingObject:ds1];
NSLog(@"arrrrr '%@'",arrayout);
Upvotes: 3
Views: 14585
Reputation: 93
You can also do it this way:
NSMutableArray *arrayout = [[NSMutableArray alloc] init]; // alloc here
[arrayout insertObject:@"SomeText Here" atIndex:[arrayout count]]; // insert here
NSLog(@"Appended Array: '%@'",arrayout); // Print here
this will populate arrayout
with SomeText Here
.
Hope it helps!
Upvotes: 4
Reputation: 5164
Try this out:
NSString *ds1 = @"--";
[arrayout addObject:ds1];
NSLog(@"arrrrr '%@'",arrayout);
Hope this helps you.
Upvotes: 6
Reputation: 12325
Why are you concatenating strings like this ? You can just do something simple like
NSString* newString = [NSString stringWithFormat:@"%@/%@/%@", string1, string2, string3];
Upvotes: 2