I use Core data to enter song data into the database. I have 3 views for this. First, select the name of the song and its detailed view to save the data in the database .. and the third view displays the saved songs. My application saves data and sometimes gives an exception.
I found when it gives an exception. If I select a song and save it to the database, it is saved correctly. But when I first turn to the 3rd look. Songlistviewcontroller, and then open the songs and try to save their details, they give an exception in the save line.
011-11-04 11:14: 10.578 SongsWithLyrics [259: 207] * - [SongsListViewController controllerDidChangeContent:]: the message was sent to the freed instance 0x5b73b50
Here is my code for saving songs
//save song details - (IBAction)saveDetails:(id)sender { NSError *error; self.song = [NSEntityDescription insertNewObjectForEntityForName:@"Song" inManagedObjectContext:managedObjectContext]; [song setValue:songTitleString forKey:@"songTitle"]; [song setValue:albumNameText.text forKey:@"albumName"]; [song setValue:artistNameText.text forKey:@"artistName"]; [song setValue:albumGenreText.text forKey:@"albumGenre"]; [song setValue:UIImagePNGRepresentation(artworkImageview.image) forKey:@"artworkImage"]; if (![managedObjectContext save:&error]) { NSLog(@"Problem saving: %@", [error localizedDescription]); } UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Saved" message:@"" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil]; [alert show]; [alert release]; [self.navigationController popViewControllerAnimated:YES]; }
I am stuck on this issue .. and cannot understand why this is happening.
Previously, my application stream was .. SongsListviewController-> Songs-> SaveSongs
And it worked great ... for that.
Please, help
source share