Sabo Sabo - 2 months ago 8
iOS Question

How to retrieve Artist lists with MPMediaQuery?

Hello i am trying to retrieve Artist with MPMediaQuery in iOS with following code.

In My ViewDidL

enter code here
oad

MPMediaQuery *query = [MPMediaQuery artistsQuery];
self.arrayOfArtist = [query collections];


And In my
cellForRowAtIndexPath


cell.textLabel.text = [NSString stringWithFormat:@"%@",[[self.arrayOfArtist objectAtIndex:indexPath.row] valueForProperty:MPMediaItemPropertyArtist]];


When i check with
NSLog
, my
arrayOfArtist
count is about 330.

However in my
UITableView
, it's only show
NULL
.

Is there anything i am wronging?

Answer

you should write:

cell.textLabel.text = [NSString stringWithFormat:@"%@",[[[self.arrayOfArtist objectAtIndex:indexPath.row] representativeItem] valueForProperty:MPMediaItemPropertyArtist]];