I read that this error occurs due to memory management issues, such as sending a message to an object that was released. I get an error right after the comment “displays information about the songs in the“ information array ”, in the first line of this second section for. Is the information array not the storage of objects that I give them in the first section for?
Any other ideas?
MPMediaQuery *query = [[MPMediaQuery alloc] init];
NSMutableArray *info;
NSArray *allSongs = [query collections];
for (MPMediaItem *recent in allSongs) {
NSDate *lastPlayed = [recent valueForProperty:MPMediaItemPropertyLastPlayedDate];
BOOL uploadInfo = [[PlayedSinceLastLogin alloc] initWithLastPlayedDateOfSong:lastPlayed] ;
if (uploadInfo == YES) {
[info addObject:recent];
}
}
for (MPMediaItem *played in info) {
NSString *playCount = [played valueForProperty:MPMediaItemPropertyPlayCount];
NSString *lastPlayed = [played valueForProperty:MPMediaItemPropertyLastPlayedDate];
NSString *songTitle =
[played valueForProperty: MPMediaItemPropertyTitle];
NSString *artistName =
[played valueForProperty: MPMediaItemPropertyArtist];
NSString *albumName =
[played valueForProperty: MPMediaItemPropertyAlbumTitle];
NSLog (@"\n %@ by %@, from album %@, played since last login.\nLast Played:%@.\nTotal Play Count: %@.", songTitle, artistName, albumName, lastPlayed,playCount);
}
source
share