If you want to be elegant, you can add a category to MPMediaItem
like this:
@implementation MPMediaItem (Readable)
- (id)readableValueForProperty:(NSString *)prop
{
id originalValue = [self valueForProperty:prop];
if (originalValue == nil) {
return @"Unknown";
}
return originalValue;
}
@end
Then you can call it like this:
NSString *artist = [currentItem readableValueForProperty:MPMediaItemPropertyArtist];
Note that this is dangerous if you're getting a property that isn't an NSString
originally. If you're operating with string values only, this should be fine, though.
An approach which is always safe but less readable (and more redundant) would be checking each and every returned value by hand:
NSString *artist = [currentItem valueForProperty:MPMediaItemPropertyArtist];
if (artist == nil) artist = @"Unknown";