Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 9, 2006, 04:26 PM   #1
HiRez
macrumors 601
 
HiRez's Avatar
 
Join Date: Jan 2004
Location: Western US
NSPopUpButton vs. Cocoa Bindings Error

Hi, I'm getting a strange error trying to bind objects into an NSPopUpButton. In Interface Builder, I have an NSArrayController bound an array in my document. I'm binding the contentObjects of my popup to the array controller, and the contentValues to a string key within the objects in the array. It all works well except for one thing:

Click image for larger version

Name:	kvo_error.jpg
Views:	18
Size:	7.9 KB
ID:	42818

The two top objects are the ones in the array, and they're correct. The goofy one on the bottom is I guess being inserted by the runtime initially, and I have no idea why. RBAudioDevice is the class of the objects in the bound content array. Now, when I select one of the other two normal items, the strange one goes away and never returns. After that, it works perfectly, but I can't get it to stop that one item from appearing when the app launches. "Automatically prepares content" does not make a difference, nor do any of the other settings. Any ideas? I've never seen this before.
__________________
Go outside, the graphics are amazing!
HiRez is online now   0 Reply With Quote
Old Mar 10, 2006, 03:02 AM   #2
caveman_uk
Guest
 
caveman_uk's Avatar
 
Join Date: Feb 2003
Location: Hitchin, Herts, UK
I have used bindings for this before and IIRC you connect contentObjects to the array controller as you've done and use the key field to select the appropriate key in the object. I don't think you need to connect contentValues as well. The currently selected object is specified using one of the 'selected...' bindings. I usually use selectedIndex.

This is all from memory so I could be mistaken...
caveman_uk is offline   0 Reply With Quote
Old Mar 10, 2006, 04:36 AM   #3
HiRez
Thread Starter
macrumors 601
 
HiRez's Avatar
 
Join Date: Jan 2004
Location: Western US
Quote:
Originally Posted by caveman_uk
I don't think you need to connect contentValues as well.
I think I had to do that because if you don't, it invokes description: on your object for the text it places in the popup (the item titles) and I didn't want that behavior (I needed a certain other string). Anyway, I may have figured it out. I think it has something to do with a situation where the KVO system gets to the popup before your code can populate it (it queries the array before it's initialized), and it inserts that dummy object. It's hard to tell since I have no way of knowing what the bindings runtime system is doing behind the back of my code.
__________________
Go outside, the graphics are amazing!
HiRez is online now   0 Reply With Quote
Old Mar 10, 2006, 05:21 AM   #4
caveman_uk
Guest
 
caveman_uk's Avatar
 
Join Date: Feb 2003
Location: Hitchin, Herts, UK
I do have to admit whilst I think the bindings systems is very useful, it isn't the panacea some people like to make out. It has a whole set of its own gotchas and if you want to do something a bit special (such as custom cells in tableviews) you're back writing datasource methods.
caveman_uk is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
NSPopUpButton Question... blackenedheart Mac Programming 8 Sep 5, 2013 06:42 AM
NSPopUpButton Question... blackenedheart Mac Applications and Mac App Store 1 Sep 3, 2013 07:18 PM
NSPopupButton selected item Dreamspinner Mac Programming 6 Dec 18, 2012 06:44 AM
Cocoa bindings questions jeanlain Mac Programming 3 Oct 6, 2012 03:20 PM
NSPopupButton Bindings knightlie Mac Programming 0 Jun 4, 2012 11:32 AM

Forum Jump

All times are GMT -5. The time now is 03:31 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps