Re: Bindings & NSArrayController
Re: Bindings & NSArrayController
- Subject: Re: Bindings & NSArrayController
- From: Tom Birch <email@hidden>
- Date: Tue, 3 May 2005 18:06:10 +1000
On 03/05/2005, at 17:49:09, Jens Miltner wrote:
Hi list,
I have a an array of dictionaries which are displayed and edited in
an NSTableView using an NSArrayController + bindings. This all
works fine, except for one issue I haven't yet solved:
Is there a way - using bindings - to set one of the dictionary
values (a boolean) whenever any other of the values is edited?
Essentially, it's something like an "I changed this value" checkbox
for each of the list entries, which should automatically be set
whenever the user edits one of the displayed column values.
you can do it but you'd probably have to modify your code to use a
custom class instead of a dictionary as the content object for the
array controller. Basically what you have to do is write your own
"setValue:forKey:" method in that custom class to insert your "I
changed this value" flag somewhere else in the dictionary
something like
- (void)setValue:(id)value forKey:(NSString *)key
{
if(![key isEqualToString:@"Modified"])
{
[self setValue:[NSNumber numberWithBool:YES]
forKey:@"Modified"];
}
[dict setValue:value forKey:key];
}
- (id)valueForKey:(NSString *)key
{
return [dict valueForKey:key];
}
I'm pretty sure this will work but it may be horribly flawed :)
cheers,
Tom
</jum> _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40cse.unsw.edu.au
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden