大家好,我有一个问题:我读出了正在播放的媒体歌曲的实际值,并将其添加到字典中。然后变成一个数组。如果我再次按下按钮添加一个新条目,所有条目的所有值都将更改为相同。你有什么想法吗?
这是我的代码:
- (IBAction)ActionButtonLU:(id)sender
{
MPMediaItem *currentItem = [musicPlayer nowPlayingItem];
NSString *titleString = [currentItem valueForProperty:MPMediaItemPropertyTitle];
NSString *artistString = [currentItem valueForProperty:MPMediaItemPropertyArtist];
NSString *albumString = [currentItem valueForProperty:MPMediaItemPropertyAlbumTitle];
if (titleString == nil) {
titleString = @"";
}
if (artistString == nil) {
artistString = @"";
}
` `if (albumString == nil) {
albumString = @"";
}
[_dictCat1 setObject:titleString forKey:@"Titel"];
[_dictCat1 setObject:artistString forKey:@"Artist"];
[_dictCat1 setObject:albumString forKey:@"Album"];
[_countCat1 addObject:_dictCat1];
[musicPlayer skipToNextItem];
}