If I instantiate an NSArray passing it an NSMutableArray, does it become a NSArray or does it just appear to be one.
i.e. is the mutable array eventually released
- (NSArray *)getObjectivesWithPerspective:(Perspective *)perspective
{
NSMutableArray *result = [NSMutableArray array];
for (ObjectiveManagedObject *objective in self.objectives)
{
if (objective.perspective.objectID == perspective.objectID) {
[result addObject:objective];
}
}
return [NSArray arrayWithArray:result];
}
You can find some info about this here: what does -arrayWithArray actually DO?. But the array you get back should be immutable. NSArray will copy the references into an immutable array.
If in doubt do a test. Get an array back from the method, cast it as a NSMutableArray and try to add an object. You should get an error when you do this.