I wish to fetch a MPMediaItemCollection
or NSArray
of all artists in a user's library. Here's my current code (which obviously doesn't work):
- (void)viewDidLoad
{
[super viewDidLoad];
MPMediaQuery *artistsQuery = [MPMediaQuery artistsQuery];
self.artistsArray = artistsQuery.collections;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.artistsArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ArtistsCell"];
cell.textLabel.text = [(MPMediaItemCollection *)self.artistsArray[indexPath.row] valueForProperty:MPMediaPlaylistPropertyName];
NSLog(@"%@", cell.textLabel.text);
return cell;
}