I have two nsmutablearrays
array1: searchedStores = [[NSMutableArray alloc] init];
array2: allStores; ///it holds Stores information and it is also
NSMutableArray
Now if i add objects in “searchedStores” Array
for (int i= 0; i < [allstores count]; i++){
Franchise *store = [allStores objectAtIndex:i];
if ([store.ZipCode hasPrefix:str]) /// where str is searched string
{
[searchedStores addObject:store]; // some stores information will be inserted in "searchedStores" array
}
}
Now if i remove objects from searchedStores array it will also remove objects from “allStores” array
to remove objects i am writing
[searchedStores removeAllObjects];
How can i remove objects only from “searchedStores” array. and “allStores” Array should keep its objects.
IF you are just assigning allstores array with searchedstores array then changes made in searched stores array will be reflected to allstores. You need to allocate new memory to allstores and then add objects from searchedstores array to it upon your logical behavior.