Re: NSOutlineView slow update w Core Data
Re: NSOutlineView slow update w Core Data
- Subject: Re: NSOutlineView slow update w Core Data
- From: David <email@hidden>
- Date: Wed, 5 Mar 2008 11:32:25 -0500
I figured out a way around it. I added code in the controller to send the
"processPendingChanges" message to the ManagedObjectContext. That flushes
pending changes, but I still don't understand why this is needed.
On Wed, Mar 5, 2008 at 12:14 AM, David Melgar <email@hidden> wrote:
> I have an NSOutlineView subclass bound to a NSTreeController subclass
> which is bound to a simple data model representing a hierarchical tree
> structure.
> I've implemented drag and drop by having the view send a custom message to
> my NSTreeController subclass who then updates the model. The problem is that
> there is then a delay of about 1 second before the view displays the added
> node.
>
> I've noticed that if I move the mouse out of the OutlineView, then it
> seems to update immediately. Any idea what I maybe doing wrong? Is it
> possible that core data and all the observing patterns are really taking
> this long to percolate the change back to the view? Am I supposed to do
> something to wake up the view faster?
>
> I'm using Leopard (10.5.2), XCode 3, Objective-C 2.0. I don't have any
> code to deal with memory management. If I run with garbage collection
> unsupported, the OutlineView never updates UNTIL I move the mouse out of the
> OutlineView. If garbage collection is enabled, there is the 1 second delay.
> With garbage collection supported, there are no errors or exceptions listed
> in the console.
>
> MyOutlineView has the following method
>
> - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender {
>
> NSPasteboard *pboard;
>
> NSDragOperation sourceDragMask;
>
> sourceDragMask = [sender draggingSourceOperationMask];
>
> pboard = [sender draggingPasteboard];
>
> if ( [[pboard types] containsObject:NSFilenamesPboardType] ) {
>
> NSArray *files = [pboard propertyListForType:NSFilenamesPboardType
> ];
>
> if (myTreeController != NULL) {
>
> [myTreeController addFiles:files];
>
> }
>
> }
>
> return YES;
>
> }
>
> MyTreeController method is as follows:
>
> - (void)addFiles:(NSArray *)droppedFilenames {
>
> NSManagedObjectContext *moc = [self managedObjectContext];
>
> for (NSString *name in droppedFilenames) {
>
> NSManagedObject *bfile = [NSEntityDescription
> insertNewObjectForEntityForName:@"bFiles" inManagedObjectContext:moc];
>
> [bFile setName: name];
>
> }
>
> }
>
>
> The model is:
>
> Entity name: bFiles
>
> Attribute: name
>
> relationship: parent, optional, bFiles
>
> relationship: child, optional, bFiles
>
>
> I have MyTreeController nib configured with the following attributes
>
> Keypaths: children = children
>
> Options: avoid empty selection, preserve selection, select inserted
> objects
>
> ObjectController:
>
> Mode=Entity
>
> Entity name = bFiles
>
> Prepares content, editable
>
>
> I have MyTreeController bound as follows:
>
> Parameters, ManagedObjectContext
>
> bind to File's Owner
>
> Model key path = managedObjectContext
>
> Raises for not applicable keys
>
>
> I don't have my NSOutlineView bound to anything but I do have the
> contained TableColumn bound as follows:
>
> Value: bind to: Tree Controller
>
> Controller Key = arrangedObjects
>
> Model Key Path = name
>
> Allows editing multiple value selection
>
> Creates sort descriptor
>
> Raises for not applicable keys
>
>
> Thats about everything pertinent that I can think of. Any suggestions
> appreciated.
>
_______________________________________________
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