-3

int main(int argc, const char * argv[]) { @autoreleasepool {

    NSMutableArray *myMute;
    NSString *stringOne = @"This is string 1";
    NSString *stringTwo = @"This is string 2";
    NSString *stringThree = @"This is string 3";

    [myMute addObject: stringOne];
    [myMute addObject: stringTwo];
    [myMute addObject: stringThree];

    NSLog(@"There are %li objects in the myMute array", [myMute count]);


    return 0;
}

}

lefkos
  • 1
  • 1
  • and [Empty NSMutableArray](https://stackoverflow.com/questions/11632308/), [NSMutableArray always emtpy](https://stackoverflow.com/questions/12892597/), [Having trouble adding objects to NSMutableArray](https://stackoverflow.com/questions/851926/), [Cannot add items to NSMutableArray](https://stackoverflow.com/questions/7125326/) – jscs Aug 23 '17 at 23:19

1 Answers1

-1

Just allocate array you create nil array you have to allocate it memory with new or alloc

NSMutableArray *myMute = [NSMutableArray new];

    NSString *stringOne = @"This is string 1";
    NSString *stringTwo = @"This is string 2";
    NSString *stringThree = @"This is string 3";

    [myMute addObject: stringOne];
    [myMute addObject: stringTwo];
    [myMute addObject: stringThree];

    NSLog(@"There are %li objects in the myMute array", [myMute count]);


    return 0;
Abdelahad Darwish
  • 5,969
  • 1
  • 17
  • 35