How to add string objects to NSMutableArray

前端 未结 6 1182
难免孤独
难免孤独 2021-01-01 10:06

I have an NSMutableArray named randomSelection:

NSMutableArray *randomSelection;

I am then trying to add strings to this array if certain c

6条回答
  •  自闭症患者
    2021-01-01 11:04

    I think you are missing to allocate the memory for array. So try this

    NSMutableArray *randomSelection = [[NSMutableArray alloc] init];
    [randomSelection addObject:@"string1"];
    NSString *test = [randomSelection objectAtIndex:0];
    NSLog(test);
    

提交回复
热议问题