Retrieve release date of album?
OK, I've asked this already in the iphone dev forums with no response. Maybe someone here can help me out.
I'm trying to retrieve the release date for ablums from the user's music library.
I have something like this...but it always returns the same year (1800).
NOTE: selectedArtist is just a string for the artist the user selected.
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy"];
MPMediaQuery *query = [MPMediaQuery albumsQuery];
[query addFilterPredicate:[MPMediaPropertyPredicate predicateWithValue:selectedArtist forProperty:MPMediaItemPropertyArtist]];
NSArray *tempList = [query collections];
int i = 0;
while (i < [tempList count])
{
MPMediaItemCollection *album = (MPMediaItemCollection *)[tempList objectAtIndex:i];
NSString *tmpInfo = [[NSString alloc] initWithString:[dateFormatter stringFromDate:[[album representativeItem] valueForProperty:MPMediaItemPropertyReleaseDate]]];
NSLog(tmpInfo);
i++;
}
Not sure why this isn't working. I know the info is in there somewhere since the correct year gets displayed when playing it in the iPod.
Any help would be appreciated, thanks.
NOTE: I've also tried retrieving the date on the first song from the album...but the results are the same, still 1800 is returned.
__________________
iPhone/iPod Touch Apps by Tiny Tech Studios
|