Re: Using bindings with an NSArray of NSStrings ?
Re: Using bindings with an NSArray of NSStrings ?
- Subject: Re: Using bindings with an NSArray of NSStrings ?
- From: Allan Odgaard <email@hidden>
- Date: Fri, 19 Mar 2004 20:56:21 +0100
On 16. Mar 2004, at 21:10, Bjoern Kriews wrote:
I have come across a few occasions where parts of my model are so
simple that I'd like to use just NSArrays of NSStrings. As far as I
know now, I have to resort to making them into dictionaries with one
key each.
Is there an elegant way to solve this (getting away without the
dictionaries ?)
If you only want to display the strings, e.g. for the user to make a
selection or similar, you can add this category to NSString:
@interface NSString (KVC)
- (NSString*)value;
@end
@implementation NSString (KVC)
- (NSString*)value { return self; }
@end
That way, you can supply 'value' as model key, and you get by the
problem with 'selection' being a proxy object instead of the real
string.
If you also want to support editing of the strings, it would in theory
be possible to implement "setValue:" in a NSMutableString category,
using setString: (and make the array controllers object class be
NSMutableString). But at least when I do so, then it goes into
infinite recursion calling NNSString's retain before even reaching my
setValue: -- I think this is a bug somewhere, but I'll need to look
closer into it...
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.