How can i copy a MutableArray in the same zone as the old one?

86 Views Asked by At

How can i add a mutable array in the same like the old one?

I tried this code but it doesn't work:

 - (void)didParsingApiBusinesses:(NSMutableArray *)businesses
 {
     NSZone *zone = [entriesBusinessesArray zone];
     entriesBusinessesArray = [businesses mutableCopyWithZone:zone];
 }
2

There are 2 best solutions below

0
On

Two things:

  1. Zones aren't used by the framework anymore.
  2. You shouldn't call mutableCopyWithZone: directly; instead call mutableCopy.

So all you need is:

- (void)didParsingApiBusinesses:(NSMutableArray *)businesses
{
    entriesBusinessesArray = [businesses mutableCopy];
}
1
On

Use mutableCopy directly.

I think NSZone is not supported by objective C now.

Thank you.