• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Using bindings with an NSArray of NSStrings ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using bindings with an NSArray of NSStrings ?


  • Subject: Re: Using bindings with an NSArray of NSStrings ?
  • From: Bjoern Kriews <email@hidden>
  • Date: Sat, 20 Mar 2004 00:26:19 +0100

On 19.03.2004, at 20:56, Allan Odgaard wrote:

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.


Thanks a lot ! I was too narrow-minded so see this option.

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...

Sounds familiar. I often run into this when fiddling around with unusal bindings stuff.

Regards, Bjoern
_______________________________________________
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.


References: 
 >Using bindings with an NSArray of NSStrings ? (From: Bjoern Kriews <email@hidden>)
 >Re: Using bindings with an NSArray of NSStrings ? (From: Allan Odgaard <email@hidden>)

  • Prev by Date: Re: key combinations while the screen is captured
  • Next by Date: Re: [Solved partially] NSTask with complexe command
  • Previous by thread: Re: Using bindings with an NSArray of NSStrings ?
  • Next by thread: "Designated Initializer" pattern
  • Index(es):
    • Date
    • Thread