• 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: The Problems with NSController (Undo)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: The Problems with NSController (Undo)
      • From: Jonathan Wight <email@hidden>
References: 
 >The Problems with NSController (From: Aaron Hillegass <email@hidden>)
 >Re: The Problems with NSController (From: Don Briggs <email@hidden>)

  • Prev by Date: Re: The Problems with NSController
  • Next by Date: Re: XCode for Jaguar?
  • Previous by thread: Re: The Problems with NSController
  • Next by thread: Re: The Problems with NSController (Undo)
  • Index(es):
    • Date
    • Thread