TreeController, OutlineView, CoreData
TreeController, OutlineView, CoreData
- Subject: TreeController, OutlineView, CoreData
- From: Raimond Hettrich <email@hidden>
- Date: Sun, 22 May 2016 11:43:25 +0200
Hallo All,
I have a view-based OutlineView with one column bound to an TreeController (arrangedObjects) and the TableViewCell bound to objectValue.name. The TreeController is bound to the managedObjectContext.
Nearly everything is fine. With the Add-Button a new line will be added with the default Value of my entity attributes. And with the Add Child Button a child will be added. The Remove-Butten removes the selected row.
The only problem is, that I can’t save the values. The Save-Action in the AppDelegate is bound to the Save-Item of the File-Menu. If I tab cmd+s the file menu in the titlebar becomes blue.
So I added the following logs:
- (IBAction)saveAction:(id)sender {
if (![[self managedObjectContext] commitEditing]) {
NSLog(@"%@:%@ unable to commit editing before saving", [self class], NSStringFromSelector(_cmd));
}
NSError *error = nil;
if ([[self managedObjectContext] hasChanges] && ![[self managedObjectContext] save:&error]) {
[[NSApplication sharedApplication] presentError:error];
}
NSLog(@"has Changes %hhd", _managedObjectContext.hasChanges);
NSLog(@"11499 moc %@ has %lu insertedObjects“,
[self managedObjectContext],(unsigned long)[[[self managedObjectContext] insertedObjects] count]);
NSLog(@"11876 Before saving, &error = %x", &error) ;
BOOL savedOK = [[self managedObjectContext] save:&error] ;
NSLog(@"11935 savedOK = %d", savedOK) ;
NSLog(@"12500 NSError saving = %@", error) ;
After starting the app I used the cmd+s command an the following log info appears:
2016-05-15 13:22:48.370 Objectiv_C_Basics[5599:360406] has Changes 0
2016-05-15 13:22:48.370 Objectiv_C_Basics[5599:360406] 11499 moc <NSManagedObjectContext: 0x6080001c1c20> has 0 insertedObjects
2016-05-15 13:22:48.370 Objectiv_C_Basics[5599:360406] 11876 Before saving, &error = 5fbfef20
2016-05-15 13:22:48.371 Objectiv_C_Basics[5599:360406] 11935 savedOK = 1
2016-05-15 13:22:48.371 Objectiv_C_Basics[5599:360406] 12500 NSError saving = (null)
Then I added rows and changed their values and I used the cmd+s command again:
2016-05-15 13:23:19.130 Objectiv_C_Basics[5599:360406] has Changes 0
2016-05-15 13:23:19.130 Objectiv_C_Basics[5599:360406] 11499 moc <NSManagedObjectContext: 0x6080001c1c20> has 0 insertedObjects
2016-05-15 13:23:19.130 Objectiv_C_Basics[5599:360406] 11876 Before saving, &error = 5fbfef20
2016-05-15 13:23:19.130 Objectiv_C_Basics[5599:360406] 11935 savedOK = 1
2016-05-15 13:23:19.130 Objectiv_C_Basics[5599:360406] 12500 NSError saving = (null)
So, if I used the correct logs I think that the managedObjectContext don’t get rid of the created changes in the OutlineViews column.
Do you have an idea where the problem could be?
Many Thanks,
Raycord
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden