With regards to MPMediaItem
, is there a way to get a property for multiple items/for items in a media item collection, which is more efficient than calling valueForProperty:
on each item separately?
I'm aware of enumerateValuesForProperties:usingBlock:
, but this allows to batch get multiple properties of a single media item. I'm interested in a single property of multiple media items.
Unfortunately you really do have to do them one at a time, but there are a couple of practical ways to do this. For example, if you want to load the values into an array you could use this for-in loop:
for (MPMediaItem *item in myCollection.items) {
[someMutableArray addObject:[item valueForProperty:MPMediaItemPropertyTitle]];
}
Or if you want to use block enumeration here's an example of what that could look like:
[myCollection.items enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop){
[someMutableArray addObject:[(MPMediaItem *)[myCollection.items objectAtIndex:idx] valueForProperty:MPMediaItemPropertyTitle]];
}];