initial value of an NSPopupButton shows with delay
initial value of an NSPopupButton shows with delay
- Subject: initial value of an NSPopupButton shows with delay
- From: Koen van der Drift <email@hidden>
- Date: Thu, 16 Aug 2012 18:53:14 -0400
I have an NSPopupButton that is bound to an NSArrayController in IB as follows:
Content -> ac.arrangedObjects
ContentValue -> ac.arrangedObjects.name
SelectedObject -> File's Owner.self.currentObject
The ac is bound to entities that are in my CD store (which are created when the app starts up for the first time, following the code example for the "Type" entity in the Grokking Recipes app from Zarra's Core Data book). I am using the SelectedObject binding so that when the popup is changed, I immediately get the selectedobject from the ac. This works like a charm.
Now when the view first appears, I'd like to set the NSPopupButton to a default value, so I added this to awakeFromNib of my NSViewController to get the entity with the name "defaultName":
NSManagedObjectContext *moc = [[NSApp delegate] managedObjectContext];
NSArray *results = [moc fetchObjectsForEntityName: @"MyObject" withPredicateString: @"name == %@", @"defaultName"];
(that last line is based on this article: http://cocoawithlove.com/2008/03/core-data-one-line-fetch.html)
then I set the currentObject to that entity:
self.currentObject = [results lastObject];
It works, I get the entity with defaultName as the initial value in the popup, but for a split second, I first see something else, as if there is some delay before the popup is set to the correct item.
Is this delay because I do a fetch in my CD store? If so is there a faster way to do this, to prevent the delay?
- Koen.
_______________________________________________
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