At 20:21 -0800 11/1/09, Quincey Morris wrote:
On Jan 11, 2009, at 05:25, Russell Martin wrote:
Here's the source of changeKeyPath:
- (void)changeKeyPath:(NSString *)keyPath
ofObject:(id)obj
toValue:(id)newValue
{
// setValue:forKeyPath: will cause the key-value observing method
// to be called, which takes care of the undo stuff
[obj setValue:newValue forKeyPath:keyPath];
}
OK, so you've found the definition of the method. You certainly
can't tell from this definition alone whether it's overriding
something else, but you've eliminated the possibility of its
overriding something else in your (or Hillegass's) code by searching
for it, and you've eliminated the possibility of its overriding
something in the Cocoa frameworks (or something similar, like being
a delegate method) by checking the documentation. So it's just a
method.
I've dug out my exercise code for the RaiseMan example and so far as
I can see -changeKeyPath is called from -observeValueForKeyPath in
MyDocument.m:
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
NSUndoManager *undo = [self undoManager];
id oldValue = [change objectForKey:NSKeyValueChangeOldKey];
// NSNull objects are used to represent nil in a dictionary
if (oldValue == [NSNull null]) {
oldValue = nil;
}
NSLog(@"oldValue = %@", oldValue);
[[undo prepareWithInvocationTarget:self] changeKeyPath:keyPath
ofObject:object
toValue:oldValue];
[undo setActionName:@"Edit"];
}
I seem to recall that Undo functionality is added well on in the
chapter so maybe you just haven't been asked to create this method
yet.
HTH
-Alan.
--
Alan Staniforth ** a...@apollonia.org
"Meum est propositum/In taberna mori,/Ut sint vina proxima/Morientis ori."
-- Anon.
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com