I built an app that must access the iTunes library. I used MPMediaQuer to retrieve songs from the library as in the following.
MPMediaQuery *media = [[MPMediaQuery alloc]init];
NSArray *arr = [media items];
for(MPMediaItem *song in arr)
{
//To print songs title
NSString *title = [song valueForProperty:MPMediaItemPropertyTitle];
NSLog(@"%@", title);
}
But nothing printed!
And I tried to print the count of the arr
array and the result is 0 as in the following.
NSLog(@"%D",[arr count]);
And I'm sure there are some songs in the iTunes Library.
Do this problem occur because I test in the simulator? And if I test the code on device should it work?
The iPod Library Access APIs only works on devices, that's why you aren't getting any result on the iPhone Simulator: