I realize I created another thread like this two years ago. My problem then was a bit different.
My problem now is this: I have an NSManagedObject containing an NSMutableArray of NSIndexPaths. As before, all changes persist only in RAM.
Edit: My NSMutableArray is stored in Core Data under a "Transformable" attribute.
I enabled SQL debugging & checked my log, and it shows that my app is SELECTing, but not UPDATEing. No errors were printed.
Edit #2: It looks like I hit a little quirk: Apparently, Core Data has a little problem with mutable types of classes. It doesn't like the fact that I've declared an NSMutableArray property; the workaround, apparently, is to configure my property accessor so it returns an immutable type. I can still use an NSMutableArray, however, to store my property's values.
Edit #3: Tried this, and it didn't work:
My problem now is this: I have an NSManagedObject containing an NSMutableArray of NSIndexPaths. As before, all changes persist only in RAM.
Edit: My NSMutableArray is stored in Core Data under a "Transformable" attribute.
Code:
//NSManagedObject subclass
-(void)awakeFromInsert
{
[superawakeFromInsert];
if (!self.placeIndexPath) {
[self setPlaceIndexPath:[[NSMutableArrayalloc] initWithObjects:[NSIndexPathindexPathForItem:0inSection:0], nil]];
}
}
Code:
// Code I use to save a new index path.
[[UserEntity sharedEntity].placeIndexPath insertObject:newIndexPath atIndex:level]; // This works.
NSError *error;
if (![[[UserEntity sharedEntity] managedObjectContext] save:&error]) {
NSLog(@"An error occured while trying to save the user's place: %@",[error localizedDescription]);
}
I enabled SQL debugging & checked my log, and it shows that my app is SELECTing, but not UPDATEing. No errors were printed.
Edit #2: It looks like I hit a little quirk: Apparently, Core Data has a little problem with mutable types of classes. It doesn't like the fact that I've declared an NSMutableArray property; the workaround, apparently, is to configure my property accessor so it returns an immutable type. I can still use an NSMutableArray, however, to store my property's values.
Edit #3: Tried this, and it didn't work:
Code:
//UserEntity.h
@interface UserEntity : NSManagedObject
@property (nullable, nonatomic, retain) NSString *name;
@property (nonatomic) int16_t nextLevel;
@property (nonatomic,strong,readonly) NSArray *placeIndexPath;
@end
//UserEntity.m
@interfaceUserEntity ();
@property (strong,nonatomic) NSMutableArray *placeIndexPath;
@end
Last edited: