Re: NSArrayController, NSPopupMenu, defaults and arrangedObjects
Re: NSArrayController, NSPopupMenu, defaults and arrangedObjects
- Subject: Re: NSArrayController, NSPopupMenu, defaults and arrangedObjects
- From: Steven Hamilton <email@hidden>
- Date: Mon, 8 Dec 2008 22:18:16 +1000
Hi folks,
I've got a single NSPopupButton. The content is bound to an
NSArrayController arrangedObjects and value bound an attribute. All
good. THe ArrayController is sourcing a Core Data store for its array
and this is all good too. The problem is when the window is loaded the
NSPopupButton is showing "No Value" which I assume is because it
hasn't been told which object in the array it should be showing by
default. I have the NSPopupButton SelectedObject bound to an
NSManageObject *selectedAccount variable in my custom window
controller.
Moving the NSPopup correctly points my selectedObject variable at the
object chosen. However, in my attempts to remove the default "No
Value" I'm attempting to set the SelectedObject variable to the first
object in the array.
selectedObject = [[myArrayController arrangedObjects] objectAtIndex:
0];
This doesn't work as the arrangedObject array is empty. NSLog returns
a count of zero.
This is the correct way to set the default on an NSPopup isn't it? I
set the bound selectedValue, not the control itself. Why is my
arrangedObjects array empty on window load?
My, is that english? I really need to slow down a bit. I'll try and
explain a bit better.
I have a custom NSWindowController called budgetController. Interface
thus (cropped a bit)
@interface MLBudgetController : NSWindowController {
IBOutlet NSArrayController *incomeEnvelopeController;
NSManagedObject *selectedIncomeEnvelope;
}
My window has an NSPopupButton bound to my NSArraycontroller
*incomeEnvelopeController. The selectedObject binding is bound to the
selectedIncomeEnvelope above. The controller sources Core Data for my
"Envelope" entities and on running, it fetches and displays the set of
entities fine showing the correct values. It also sets the
selectedIncomeEnvelope fine too.
But on first load I have a "No Value" in the popup. Selecting an entry
removes the No Value from the list. In my budgetController's
windowDidLoad{} function I'm attempting to set the
selectedIncomeEnvelope to the first object in the array like so;
selectedIncomeEnvelope= [[incomeEnvelopeController arrangedObjects]
objectAtIndex:0];
However, the arrangedObjects array, while existing, contains zero
objects. I've checked the Outlet is connected ok. A timing issue of
some sort?
_______________________________________________
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