I created my app using Core Data, declared 2 attributes, SongLyrics and MovieSongName, both as string. Then in xib I created a text field for MovieSongName and a text view for SongLyrics. For storing these I used the following code
-(void)saveData
{
LyricsAppDelegate *appDelegate = [[UIApplication sharedApplication]
delegate];
NSManagedObjectContext *managedObjectContext = [appDelegate managedObjectContext];
NSEntityDescription *entityDesc = [NSEntityDescription
entityForName:@"Lyrics"
inManagedObjectContext:managedObjectContext];
NSManagedObject *LyricsObjectEnglish;
LyricsObjectEnglish = [NSEntityDescription
insertNewObjectForEntityForName:@"English_Songs"
inManagedObjectContext:managedObjectContext];
[LyricsObjectEnglish setValue:song_lyrics.text forKey:@"SongLyrics"];
[LyricsObjectEnglish setValue:song_name forKey:@"MovieSongName"];
song_lyrics.text=@"";
song_name.text=@"";
NSError *error;
[managedObjectContext save:&error];
}
when clicking on the save button app gets aborted with the following error.
2012-01-27 10:50:52.071 Lyrics[4624:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unacceptable type of value for attribute: property = "MovieSongName"; desired type = NSString; given type = UITextField; value = >.'
Can any one help me? I'm using Core Data for the first time and I'm a little confused.