ADDING STRINGS INTO NSMUTABLEARRAY

Glen Martin

Total Post:27

Points:191
Posted by  Glen Martin
 600  View(s)
Ratings:
Rate this:
I have created 2 variables of NSString and 1 variable of NSMutableArray,
Now I want to add both string variables into mutable array.

can any one tell me how to do it?
  1. Tarun Kumar

    Post:214

    Points:1642
    Re: Adding Strings into NSMutableArray

    If you want to add NSString objects into array,
    then I'll try to show you both Mutable and Immutable array example but I would recommend using an Immutable version:
    Mutable version:

    NSMutableArray *mutableObject = [[NSMutableArray alloc] init];
    NSString *stringObj1 = @"string1"];
    [mutableObject addObject:stringObj1];
    //or
    [mutableObject addObject:@"string2"];
    NSLog(@"%@", mutableObject);

    Immutable version:

    NSArray *immutableObject = [NSArray arrayWithObjects:@"string1", @"string2", nil];
    NSLog(@"%@", immutableArray);

      Modified On Nov-08-2015 10:59:06 PM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!