I am trying to use the Auto Save Advanced Elements feature. When I expand the group with my children and restart the application, all the children crash again, and I donβt know why they will not stay extended. I use basic data to store the elements of the original list.
This is what I have done / installed so far:
- Checked "Autosave of Extended Elements" in NSOutlineView (list of sources)
- Set a name for "Autosave"
- dataSource and delegates assigned to my controller
This is my implementation for outlineView: persistentObjectForItem and outlineView: itemForPersistentObject.
- (id)outlineView:(NSOutlineView *)anOutlineView itemForPersistentObject:(id)object { NSURL *objectURI = [[NSURL alloc] initWithString:(NSString *)object]; NSManagedObjectID *mObjectID = [_persistentStoreCoordinator managedObjectIDForURIRepresentation:objectURI]; NSManagedObject *item = [_managedObjectContext existingObjectWithID:mObjectID error:nil]; return item; } - (id)outlineView:(NSOutlineView *)anOutlineView persistentObjectForItem:(id)item { NSManagedObject *object = [item representedObject]; NSManagedObjectID *objectID = [object objectID]; return [[objectID URIRepresentation] absoluteString]; }
Any ideas? Thanks.
EDIT: I have a key! The problem, perhaps, is that the tree controller did not prepare its content on time. ApplicationDidFinishLaunching, outlineView: persistentObjectForItem methods, etc. Run before data is loaded, or rather, NSOutlineView has not yet completed initialization. Any ideas how to solve this?
Sylox source share