Greetings

I got my NSPopUpButton working, but have been informed that it is done wrong. The last time I submitted this it had a typo and I was chastised and told to read the Objective-C introduction, so the question wasn't addressed.

I'd like to submit this bare-bones example for comment.

Description:

- One class, named PopUp, subclass of NSObject

Code:

//  Popup.h
//  TestPopup

#import <Cocoa/Cocoa.h>
@interface Popup : NSObject
{
        NSArray *popupArray;
        NSString *selectedGame;
}
@property (readwrite, copy) NSArray *popupArray;
@property (readwrite, copy) NSString *selectedGame;
@end
==============================================
//  Popup.m
//  TestPopup

#import "Popup.h"
@implementation Popup: NSObject
@synthesize popupArray;
@synthesize selectedGame;

- (void) awakeFromNib
{
[self setPopupArray: [NSArray arrayWithObjects:@"C9", @"F11", nil]];
self.selectedGame = @"C9";
}
@end


Interface Builder nib file MainMenu.nib:

One (1) NSPopUpButton.
One (1) NSArrayController named popUpController. Its class identity is left as NSArrayController, as is its "Object Controller Class Name" (set in Attributes pane).

Bindings for the NSPopUpButton:
All three "content" bindings set to popUpController.arrangedObjects.self

QUESTION: How would you implement the binding to the model objects "popUpArray" and "selectedGame" so that the popup loads from "popUpArray" and its selection is kept in sync with the property "selectedGame?" Specifically, is there a way to do it without instantiating the object PopUp in the nib file?

I know how I have done it, and page 118 of Aaron's 3rd edition says the same, but I want to hear if there is a "pure" MVC-compliant way to do it.

Thanks. _______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to