I get this error message:-[MPConcreteMediaItem isEqualToString:]: unrecognized selector sent to instance…
I am creating an NSMutable array of songs from media picker into an array named “array”. This array shows up properly in the tableview (myTable). HOWEVER when I try to segue to the detail view and send the song title to a label on the detail view following this tutorial. I get the crash and error message above.
Appreciate any help, thanks!
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"detailView"]) {
NSIndexPath *indexPath = [self.myTable indexPathForSelectedRow];
DetailViewController *vc = [segue destinationViewController];
vc.trackName = [array objectAtIndex:indexPath.row];
//crashes -[MPConcreteMediaItem isEqualToString:]: unrecognized selector sent to instance
}
}
- (void)mediaPicker:(MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection {
[array addObjectsFromArray:mediaItemCollection.items];
[myTable reloadData];
// mediaItemCollection = nil;
[mediaPicker dismissViewControllerAnimated:YES completion:nil];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//this method is called to fill out table with data
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"Cell"];
}
// Configure the cell
anItem = nil;
anItem = [array objectAtIndex:indexPath.row];
cell.textLabel.text = [anItem valueForProperty:MPMediaItemPropertyTitle];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
return cell;
}
The error looks like that you aren’t calling ‘isEqualToString:’ on a string object… Which superclass has MPConcreteMediaItem