0

Everytime i copy data from array to mutable array, the previous content in the mutable array is lost.

This is my code.

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


         j= [o isEqualToString:oo];

         if (j==1)
         {


             dummymarray = [marray objectAtIndex:i];

         }
       }
1
  • try to add object from existing array so you can not loss previous data Commented Feb 22, 2017 at 6:12

2 Answers 2

1

Supposing the dummyArray is the Mutable Array, you like to append the values coming from the working array:marry.

[dummyArray addObject:[marray objectAtIndex:i]];
Sign up to request clarification or add additional context in comments.

Comments

0

addObject to dummyarray:

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];
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.