2011-07-08 78 views
0

以下代碼檢索出現在我的iPhone中的所有歌曲,但我想要檢索數組中的所有歌曲。我的意思是我可以有陣列中的歌曲名稱陣列嗎?如果是,那該怎麼辦?如何檢索數組中歌曲庫的歌曲列表?

Thanks-

MPMediaPickerController *picker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic]; 

picker.delegate = self; 
picker.allowsPickingMultipleItems = YES; 
picker.prompt = NSLocalizedString (@"Add songs to play", "Prompt in media item picker"); 

[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault animated: YES]; 

[self presentModalViewController: picker animated: YES]; 

[picker release]; 

回答

2

iPod Library Access Programming Guide。其中有一個示例向您顯示與整個媒體庫相匹配的媒體查詢,可讓您將其放入數組中:

MPMediaQuery *everything = [[MPMediaQuery alloc] init]; 

NSLog(@"Logging items from a generic query..."); 
NSArray *itemsFromGenericQuery = [everything items]; 
for (MPMediaItem *song in itemsFromGenericQuery) { 
     NSString *songTitle = [song valueForProperty: MPMediaItemPropertyTitle]; 
     NSLog(@"%@", songTitle); 
} 
+0

感謝Espresso! – Developer