I have an array of custom objects, say Messages.
These messages have an identifierproperty and I'd like to know what's the most optimal way to get an array of NSString from all those identifiers.
Right now, I'm just looping through all the objects and putting their id in another array,
- (NSArray*)getIdentifiersOf:(NSMutableArray*)array
NSMutableArray *arrIdentifiers = [[NSMutableArray alloc]init];
for (Message *msg in array){
[arrIdentifiers addObject:msg.identifier];
}
return (NSArray*)arrIdentifiers;
Obviously this works, but it seems so redundant I thought you might think of something else.
I usually just need to send an array of Id's as parameter for example, and I was thinking something along the lines of
myArray[@"identifier"]
that could automatically use the array but only that specific property for every object inside it.