On Jan 31, 2010, at 13:16, Daniel Wambold wrote:
> Previous problem solved:
> A few weeks ago, I posted a question pertaining to trouble I was having when
> tableView column header cell titles contained period (.) characters. After
> working around it, I recently discovered the source of my problem and I
> figured I'd post just in case anyone else stumbled down this same path.
> In brief, I have an NSTableView to which the user can add user-titled
> columns. I bound the tableView's columns to a controller programmatically.
> This was the root of my trouble. I chose to use the column title strings as
> the keys for the binding, like this:
>
> <code>
> [aTableColumn bind:@"value" toObject:myDataController withKeyPath:[NSString
> stringWithFormat:@"arrangedObjects.%@", [myTitleArray objectAtIndex:i]]
> options:nil];
> </code>
>
> Of course, when the %@ in the formatted string was replaced with a column
> title containing a period, the key acquired an incorrect dot-syntax
> appendage. For whatever reason, that error then caused several messages
> regarding object validation to occur, convincing me that I had accidentally
> requested object validation.
> In any event, the error was entirely mine, and periods can easily coexist
> with column titles as long as I do something like [[myTitleArray
> objectAtIndex:i] stringByReplacingOccurrencesOfString:@"." withString:@""].
Well, I don't want to rain on your parade too hard, but you haven't exactly
solved the problem.
1. The allowable structure of a key path is described in:
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/BasicPrinciples.html#//apple_ref/doc/uid/20002170
so if your column header contains illegal characters, or doesn't begin with a
lowercase letter, KVC/KVO is likely to crap out.
2. Removing periods (and, say, other illegal characters, if you were to try
that approach) might give you a legal key path, but doesn't preserve
uniqueness. By dropping periods, you could end up referring to the wrong
property name.
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]