NSArray adding elements

后端 未结 3 659
深忆病人
深忆病人 2021-02-02 06:33

I have to create a dynamic NSArray, that is, I don\'t know the size of the array or what elements the array is going to have. The elements need to be added to the array dynamica

3条回答
  •  长发绾君心
    2021-02-02 07:32

    Convert your NSArray to NSMutableArray, and then you can add values dynamically:

    NSMutableArray *mutableStringArray = [stringArray mutableCopy];
    [mutableStringArray addObject:@"theNewElement"];
    

提交回复
热议问题