Cố đoạn mã sau:Nhận năm album cho mục trong thư viện iPod?
// Per albums
MPMediaQuery *albumsQuery = [MPMediaQuery albumsQuery];
NSArray *collections = [albumsQuery collections];
for (MPMediaItemCollection *collection in collections)
{
NSDate *collectionReleaseDate = [collection valueForProperty: MPMediaItemPropertyReleaseDate];
NSLog(@"collection release date: %@", collectionReleaseDate);
MPMediaItem *representativeItem = [collection representativeItem];
NSDate *representativeItemReleaseDate = [representativeItem valueForProperty: MPMediaItemPropertyReleaseDate];
NSLog(@"representativeItem release date: %@", representativeItemReleaseDate);
}
// Just per item
MPMediaQuery *query = [[MPMediaQuery alloc] init];
NSArray *items = [query items];
for (MPMediaItem *item in items)
{
NSDate *date = [item valueForProperty: MPMediaItemPropertyReleaseDate];
NSLog(@"release date: %@", date);
}
Trong mọi trường hợp tôi nhận được của nil cho NSDates ... Nhưng trong thư viện iPod Tôi có thể thấy ngày tháng, do đó thông tin phải có sẵn. Cách chính xác để có được nó là gì?
ngày Việc phát hành là chỉ có thể sử dụng iOS 4 hoặc cao hơn. Phiên bản mục tiêu của bạn là gì? –
Sử dụng iOS SDK 4.2, mục tiêu triển khai = iOS 4.0, thử nghiệm trên iPad với 4.2.1 và iPod thế hệ thứ 2 với 4.2.1 ... – ivanzoid