Re: The Problems with NSController (Undo)
Re: The Problems with NSController (Undo)
- Subject: Re: The Problems with NSController (Undo)
- From: Mike Nowak <email@hidden>
- Date: Sun, 26 Oct 2003 15:12:25 -0500
I got this useful information from Shaun Wexler to make the first demo
in the NSController tutorial to work. See below. The lack of Undo
support is a little scary. Is there a way to easily add it? I suppose
you could do the registration with the Undo Manager in the setters,
like we used to, as in:
[[[self undoManager] prepareWithInvocationTarget:self]
setDollarsToConvert:value];
Right?
>
I wonder if you can do me a favor and look at the tutorial in:
>
>
/Developer/Documentation/Cocoa/Conceptual/ControllerLayer/Tasks/
>
ccwithbindings.html
>
>
Can you tell me if it is missing any steps? How does the controller
>
know to update the amountInOtherCurrency view when the values for
>
dollarsToConvert or exchangeRate change?
I see no NSValueTransformer, nor any bindings to perform the update, so
you'll need to choose one of several methods, the easiest of which is:
+ (void)initialize
{
[self setKeys:[NSArray arrayWithObjects:@"dollarsToConvert",
@"exchangeRate", nil]
triggerChangeNotificationsForDependentKey:@"amountInOtherCurrency"];
}
...which does the equivalent of wrapping each setter method's code like
this:
- (void)setDollarsToConvert:(double)dollars
{
[self willChangeValueForKey:@"amountInOtherCurrency"];
dollarsToConvert = dollars;
[self didChangeValueForKey:@"amountInOtherCurrency"];
}
- (void)setExchangeRate:(double)rate
{
[self willChangeValueForKey:@"amountInOtherCurrency"];
exchangeRate = rate;
[self didChangeValueForKey:@"amountInOtherCurrency"];
}
On Oct 26, 2003, at 12:52 PM, Don Briggs wrote:
>
When I first started working with NSController, I found that some of
>
Apple's examples didn't work.
>
My first thought was, "This will all settle out when Panther
>
stabilizes."
>
But with 7B85, some trouble remains.
>
And I'm experiencing trouble with Undo.
>
(See my To Many example for Panther on my .Mac home page.)
--
Mike Nowak
Work:
http://healthmedia.umich.edu/
Personal:
http://snackdog.org/
"Better out than in."
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.