Re: NSTableView Column Header Restrictions?
Re: NSTableView Column Header Restrictions?
- Subject: Re: NSTableView Column Header Restrictions?
- From: Daniel Wambold <email@hidden>
- Date: Mon, 1 Feb 2010 19:30:18 -0500
OK, first, thanks to Quincey for pointing out the document on KVO/KVB key requirements. Since I've made several mistakes along the way, I figured I'd ask if this seems adequate to ensure conversion of arbitrary strings (keyboard entered) into compliant keys. The code subsequently checks to ensure that, after the conversion, they keys are non-nil and not duplicates of existing keys. The pre-conversion string is limited to 30 characters, so I think the maximum these could end up being is something like 90 or 120 characters, given that the percent-conversion can add at least 2 characters to each one they replace. Have I missed anything important? As it is, the NSObject's bind:... method seems to take care of white space by encapsulating the key in quotation marks, but since that violates the key formation rules, I don't want to rely on that behavior. However, since it worked, I didn't realize I was making a mistake, so let me know if I've missed something else. Thanks for your input! (Incidentally, I chose the percent-escape route because it took care of the ASCII conversion and the white space elimination in one shot. Otherwise, I could have gone with a routine to strip white space, convert to data with ASCII, then back to a string, but the keys are only seen by the program, so I figured the percent format wouldn't hurt.)
-Dan
//////////
// Prepare the column title string for KVO work: Must be non-cap (initial char), ASCII, and non-white-space-containing.
myKVOCompliantKey = [myTableColumnTitleUnstripped stringByReplacingOccurrencesOfString:@"." withString:@""];
myKVOCompliantKey = [myKVOCompliantKey lowercaseString];
myKVOCompliantKey = [myKVOCompliantKey stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
// End of string prep.
//////////
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden