I have this object:
@interface Song : NSManagedObject @property (nonatomic, strong) NSString *songName; @property (nonatomic) int32_t achievedPoints;
When I set the properties as follows
Song *song1 = [[SongStore sharedStore] createSong]; song1.songName = @"Song 1"; song1.achievedPoints = 0;
everything works, however as soon as I try to set the achievedPoints variable to something other than 0, I get EXC_BAD_ACCESS.
This is what the createSong method createSong :
- (Song *)createSong { double order; if ([allSongs count] == 0) { order = 1.0; } else { order = [[allSongs lastObject] orderingValue] + 1.0; } Song *p = [NSEntityDescription insertNewObjectForEntityForName:@"Song" inManagedObjectContext:context]; [p setOrderingValue:order]; [allSongs addObject:p]; return p; }
I have no idea why getting the value and setting it to 0 works, but nothing but zero, the program crashes. Any help is appreciated.
source share