table view, popup, bindings: more grief...
table view, popup, bindings: more grief...
- Subject: table view, popup, bindings: more grief...
- From: Ondra Cada <email@hidden>
- Date: Fri, 31 Mar 2006 18:49:54 +0200
Hello all,
I've bumped into another problem with a table view containing a popup
column bound to model: As soon as the popup values differ for
different model object instances, all hell breaks loose.
A test model code may look like this:
@interface Model : NSObject {
int number; // controls the range and interpretation for tag
int tag; // for positive numbers, 0-1, for negative numbers,
0-3, for zero zero only
}
@end
@implementation Model // there's a bit more in real code--see the
archive for complete source, this is the gist
-(NSArray*)popupValues {
if (number==0) return [NSArray arrayWithObject:@"none"]; //
nothing for zero
if (number>0) return [NSArray arrayWithObjects:@"+",@"+
+",nil]; // 0-1 all right for positive
return [NSArray
arrayWithObjects:@"-",@"--",@"---",@"----",nil]; // 0-3 all right for
negative
}
@end
There is an NSArrayController which keeps an array of these Models,
and a table with two columns. First is a plain editor bound to
"number"; second is a popup whose "contentValues" are bound to
"popupValues" and "selectedIndex" bound to "tag".
One would say it's simple enough to be bound to (sorry for the
pun ;)) work, but it seems the popup cells do not sync with proper
model object, getting the "contentValues" instead from seemingly
random one: at first, the table displays all right, but as soon as it
contains objects with zero, positive, and negative numbers, and you
try to actually use the popups, ugly things occur (wrong popups
shown, values don't change when edited, "3" instead of "----"
displayed for negative "numbers", etc).
Can anybody please advice how to solve the problem? TIA!
A complete project to test it, along with slightly improved model
implementation (change of number should trigger change of popup, also
change of number zeroes tag) is at http://www.ocs.cz/apps/
TablePopupProblem.zip.
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
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