• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Conceptual MVC Help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Conceptual MVC Help


  • Subject: Conceptual MVC Help
  • From: Johnny Lundy <email@hidden>
  • Date: Tue, 20 May 2008 10:41:30 -0400

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 (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


  • Follow-Ups:
    • Re: Conceptual MVC Help
      • From: Michael Babin <email@hidden>
  • Prev by Date: Re: check if app opens with a document on startup
  • Next by Date: Re: Problem with updating NSProgressIndicator
  • Previous by thread: Re: check if app opens with a document on startup
  • Next by thread: Re: Conceptual MVC Help
  • Index(es):
    • Date
    • Thread