So this is the code I have:
At the press of a button:
-(void)mediaPicker: (MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection {
[self dismissModalViewControllerAnimated:YES];
self.selectedSong = mediaItemCollection;
NSLog(@"Selected song: %@", self.selectedSong);
}
Later on:
-(void)waitUntilSpeechIsDone {
NSLog(@"Test");
if ([audio isEqualToString:@"Music"]) {
if ([musicWhenToStart isEqualToString:@"Before"]) {
NSLog(@"Test");
NSLog(@"Selected song: %@", self.selectedSong);
[self.musicPlayer stop];
[self.musicPlayer setQueueWithItemCollection:self.selectedSong];
[self.musicPlayer play];
}
}
}
It's defined as:
@interface RewriteViewController : UIViewController <MPMediaPickerControllerDelegate> {
MPMediaItemCollection *selectedSong;
}
@property(nonatomic,retain) MPMusicPlayerController *musicPlayer;
@property(nonatomic,retain) MPMediaItemCollection *selectedSong;
MPMediaItemCollection *selectedSong;
Then both are synthesized in the .m file.
Ok, so it gets through the first half fine. The NSLog returns something like "Selected song: " Then NSLog returns "Test", (i put that there so i know it's got that far in case it crashes at the next line for some reason). Then when it gets to the next line it returns "Selected song: (null)".
Any ideas why?
EDIT: Both are released in dealloc.