如何在不覆盖可变数组中的当前数据的情况下将数据从数组附加到可变数组?

How to append data from an array to mutable array without overwriting the current data in mutable array?

每次我将数据从数组复制到可变数组时,可变数组中以前的内容都会丢失。

这是我的代码。

for (i=0;i<k;i++)
     {
        o=[[marray objectAtIndex:i]valueForKey:@"district_id"];


         j= [o isEqualToString:oo];

         if (j==1)
         {


             dummymarray = [marray objectAtIndex:i];

         }
       }

假设 dummyArray 是可变数组,您想附加来自工作 array:marry.

的值
[dummyArray addObject:[marray objectAtIndex:i]];

将对象添加到虚拟数组:

NSObject *object=[[NSObject alloc]init]; 

for (i=0;i<k;i++)
{
    o=[[marray objectAtIndex:i] valueForKey:@"district_id"];
    j=[o isEqualToString:oo];

    if (j==1)
    {
        object=[marray objectAtIndex:i];
        [dummymarray addObject:object];
    }
}