Reputation: 6392
Wondering, After building nsmutablearray should i convert it to nsarray for performance benefit? If i am going to keep and use that array for quite sometime.
Upvotes: 8
Views: 122
Reputation: 122391
No. The conversion itself will cost time and CPU cycles and you won't gain anything from the conversion.
Upvotes: 5
Reputation: 3847
I would actually say it depends. If I create a NSMutableArray within a method and needs to return it, then generally unless the caller requires the ability to directly modify the array values, I will return the NSMutableArray as a NSArray for the sake of simlicity and to reduce the memory footprint of the application.
However, if I am creating the NSMutableArray for direct consumption within the current method, then I seen no benefit of casting it to a NSArray.
Upvotes: 0