我試圖檢索我的iPod庫中歌曲的曲目號。MPMediaItem這個類不是密鑰編碼兼容密鑰
基本上我查詢了所有專輯如下:通過歌曲
MPMediaItemCollection *album = self.albums[0];
迭代和嘗試登錄的磁道數
for (MPMediaItem *mediaItem in self.album.items)
{
NSLog(@"Track Number %@", [mediaItem valueForKey:MPMediaItemPropertyAlbumTrackCount]);
}
:
NSArray *albums = [MPMediaQuery albumsQuery].collections;
檢索到的一張專輯
但是這給了我以下錯誤
Terminating app due to uncaught exception 'NSUnknownKeyException', reason:
'[<MPConcreteMediaItem 0x1cd818d0> valueForUndefinedKey:]: this class is
not key value coding-compliant for the key albumTrackCount.'
如果我嘗試其他密鑰,如MPMediaItemPropertyTitle
,MPMediaItemPropertyAlbumTitle
或MPMediaItemPropertyArtist
工作正常。有什麼我錯過了爲什麼我不能訪問MPMediaItemPropertyAlbumTrackCount
。
請檢查此問題http://stackoverflow.com/questions/11090359/faster-sort-of-nsmutablearray-of-mpmediaitems-code-review – 2013-03-19 12:24:42