Re: NSTableColumn 'enabled' binding not in 10.3? Any others?
Re: NSTableColumn 'enabled' binding not in 10.3? Any others?
- Subject: Re: NSTableColumn 'enabled' binding not in 10.3? Any others?
- From: Sam Stigler <email@hidden>
- Date: Wed, 30 May 2007 16:19:33 +1000
I just repeated your steps as outlined here, with the exception that
I did "Build and Go" instead of building and then double-clicking on
the built application. I was unable to test on Panther as I no
longer have it installed on my computer, but I was able to verify
that under 10.4.9, the "enabler" binding you have described works in
the following way: It disables the "URL" column until something is
entered in the "Enabler" column. But there is one caveat to this,
which I think may be at the root of your problem: Oddly enough, the
binding only works for numbers: While if you enter a number into the
"Enabler" column its corresponding cell in the "URL" column will be
enabled, the same is not true if you enter a string (of letters), nor
a string that contains a number but starts with a letter. Further
testing reveals that the binding will, however, work if the string
entered in the "Enabler" column" contains text (letters), but starts
with a number. This probably has to do with the Cocoa Bindings
Reference's definition of that binding (thanks to mmalc for the
link): "The NSTableColumn is enabled if a logical AND operation on
all the enabled bindings results in a Boolean value of YES." I'm not
quite sure how some of those case (for example, a combination of
letters and numbers) could could evaluate one way or the other in
terms of a Boolean value, but it would appear that is what is
happening -- since there aren't any placeholders specified for those
bindings.
It seems to me that a good workaround here would be to make a value
transformer that will come up with a Boolean value that makes sense
out of whatever is entered in the "Enabler" column.
This is because (and I'm just guessing here) probably some little
thing about the Cocoa frameworks changed between 10.3 and 10.4 in how
the "enabled" binding was implemented. I was going to say that it
probably has something to do with 10.4 tolerating non-Boolean values
and 10.3 not tolerating them, but then I noticed that your test
values were "0" and "1" -- although, of course not YES, NO, TRUE, or
FALSE. Does anyone else have any ideas?
Sam
On May 30, 2007, at 12:34 PM, Jerry Krinock wrote:
To eliminate the possibility of some very stupid project
configuration error on my part, I tried the same thing using one of
mmalc's examples, and found the same problem. Certainly this
cannot be possible. Please someone look at my reproducible steps
below and tell me what I'm doing wrong.
1. Download the latest "Bookmarks" example project:
http://homepage.mac.com/mmalc/CocoaExamples/Bookmarks.zip
2. Unzip and open project in Xcode (I'm using Xcode 2.3)
3. In Target, change:
Mac OS X Deployment Target to "Mac OS X 10.3"
Architectures to "ppc i386"
4. Set Active Build Configuration to Deployment.
5. Build.
6. Log in from my old Powerbook G4 running Panther 10.3.9.
7. Launch the built application from Powerbook and verify that it
runs OK. Quit.
8. Open the MyDocument.m nib file.
9. In the DNDController > attributes, add another key 'enabler'.
(The idea here is that we are going to 'enable' the 'url' table
column using this new attribute, 'enabler'.)
10. In the MyTableView, add another column. Set the column
heading to "Enabler".
11. Bind the new column's 'value' binding to DNDArrayController >
arrangedObjects.enabler.
12. Bind the old "URL" column's 'enabled' binding
DNDArrayController > arrangedObjects.enabler also.
13. Build the project.
14. Run the project in Tiger (I have an Intel Mac Mini). Verify
that the document window loads upon launch and that it works as
expected. Actually, it works BETTER than expected... If I type
the string '0' in the "Enabler" column, editing of the "URL" column
is disabled. If I type the string '1' in the "Enabler" column,
editing of the "URL" column is enabled. Damn, those objects are
smart! (Probably thanks to -[NSString intValue]).
15. But not so smart in Panther, because now, when I doubleclick
the built application in Panther, I get the same error as when I
run my project, and the window does not even load...
[<NSTableColumn 0xXXXXXXXX> valueForUndefinedKey:]: this class is
not key value coding compliant for the key enabled.
I also went into my project, eliminated all the tables and all the
columns except one. I found that if I un-check the "Bind" checkbox
in the 'enabled' binding, it runs OK in both Panther and Tiger.
But then if I re-activate that binding, although it still runs fine
in Tiger, it raises that same exception in Panther.
I tried un-checking the "Raises for not applicable keys" switch,
but that does not help.
It's as though the 'enabled' binding is not available in Panther,
although according to the documentation mmalc pointed me to
yesterday, it *is* available.
http://sheepsystems.com/engineering/BindingNSTableColumn.png
Jerry Krinock
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
40mac.com
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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