• 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: Binding NSPopUpButton with Option "Inserts Null Placeholder"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding NSPopUpButton with Option "Inserts Null Placeholder"


  • Subject: Re: Binding NSPopUpButton with Option "Inserts Null Placeholder"
  • From: email@hidden
  • Date: Tue, 30 May 2006 20:01:21 +0200

Okay, I could solve it without help. I've just read the manual "Key Value
Coding" and the solution was there: a custom class with the overridden method
setNilValueForKey:

#import "RegionArrayController.h"

@implementation RegionArrayController

- (void)setNilValueForKey:(NSString *)key {
	if ([key isEqualToString:@"selectionIndex"]) {
		[self setSelectionIndex:NSNotFound];
	} else {
		[super setNilValueForKey:key];
	}
}

@end




Zitat von email@hidden:

Hello,
I hope somebody could help me, spent already days for solving the following
problem with a NSPopUpButton and Bindings:

I have an NSPopUpButton and an NSArrayController bound to it. The
NSArrayController gets the data from CoreData. Because I need a 'no region'
menu item in the NSPopUpButton, I selected the option "Inserts Null
Placeholder" for the binding.

All works fine, except for the "no region" menu item, which throws an exception
"[<NSArrayController 0x1116450> setNilValueForKey]: could not set nil as the
value for the key selectionIndex." when selecting it.


What's wrong?

Here's how I set up the binding for the ArrayController:

I have a NSPopUpButton with the follwing Bindings:
content:
 Bind To: regionController (NSArrayController)
 Controller Key: arrangedObjects
 x Inserts Null Placeholder (because I need a menu item 'no region')

contentValues:
 Bind To: regionController (NSArrayController)
 Controller Key: arrangedObjects
 Model Key Path: name
 x Inserts Null Placeholder (because I need a menu item 'no region')
 Null Placeholder: no region

selectedIndex:
 Bind To: regionController (NSArrayController)
 Controller Key: selectionIndex


Thanks for helping! Marc

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden




_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Binding NSPopUpButton with Option "Inserts Null Placeholder" (From: email@hidden)

  • Prev by Date: Re: NSAttributedString drawing and NSText drawing
  • Next by Date: Re: Image cache: Where is it and how do I refresh it?
  • Previous by thread: Re: Binding NSPopUpButton with Option "Inserts Null Placeholder"
  • Next by thread: Custom Field Editor for NSTableView with bindings
  • Index(es):
    • Date
    • Thread