• 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
Re: NSArrayController access between nib files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArrayController access between nib files


  • Subject: Re: NSArrayController access between nib files
  • From: Quincey Morris <email@hidden>
  • Date: Mon, 10 Aug 2009 11:41:10 -0700

On Aug 10, 2009, at 11:04, Brian Carmalt wrote:

Let's say I want the combo box to provide the user with auto completion on the names of categories in the array controller, and if the user types in a category name that does not exist, then they will be automatically prompted to create the category. This will not work with a popup button. Will this work? or are there known pitfalls I should look out for?

I should create a new array controller in my NewObjectSheet context and set it up to use the documents MOC and bind my combo box to this new array controller, that is if I can use the NSComboBox like I described above.

Nope, it's not going to work. Suppose your document has 4 existing categories: "cheese", "fruit", "meat", "bread". Suppose you bind an array controller to the array of categories, and you bind a combo box's popup list to arrayController.arrangedObjects and you bind the combo box's value to arrayController.selection.name.


Now your sheet will open, and the combo box will show one of the categories -- let's say "fruit". If you choose a different category -- let's say "cheese" -- from the popup list, you'll actually change the category name. So the document will now have 4 categories named: "cheese", "cheese", "meat", "bread". I'm pretty sure that's not what you want.

You don't want to bind the combo box to arrayController.selection.name. If you really want to use a combo box, you'd have to bind it to a "temporary" string property of your sheet window controller. Then you'd have quite a bit of extra work to do. You'd have to prefill this text field with the correct category string at initialization. When ending the sheet, you'd have to examine the category string, decide if it was one of the standard ones, and create a new one if not. Or perhaps you'd do this when a new string was entered, and wait till the sheet ended. Plus you may need to use NSComboBox methods to determine which existing category, if any, was chosen from the popup list. Plus you might need some validation code. Plus you might need some string formatting code (capitalizing or uncapitalizing entered category names so that the appearance of all of them is consistent). It's doable, but it's a certain amount of work, because ...

"A combo box is a kind of text field, not a kind of menu."

_______________________________________________

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


References: 
 >Re: NSArrayController access between nib files (From: Brian Carmalt <email@hidden>)

  • Prev by Date: NSURLCache
  • Next by Date: [iPhone 3.0] crashes in webView:didCommitLoadForFrame:
  • Previous by thread: Re: NSArrayController access between nib files
  • Next by thread: Re: NSArrayController access between nib files
  • Index(es):
    • Date
    • Thread