On 31 Jan 2014, at 11:59 am, Quincey Morris 
<quinceymor...@rivergatesoftware.com> wrote:

> On Jan 30, 2014, at 16:30 , Graham Cox <graham....@bigpond.com> wrote:
> 
>> However, the documentation states: 
>> 
>> "If you override this method, you must call super or raise an 
>> NSInvalidArgumentException exception at the end of your implementation. In 
>> other words, this method must not return normally; it must always result in 
>> an exception being thrown."
> 
> Yeah, that wasn’t the right place to do it. The correct place sounds like 
> ‘forwardInvocation:’, about which the documentation states:
> 
>> A forwardInvocation: method can act as a distribution center for 
>> unrecognized messages, parceling them out to different receivers. Or it can 
>> be a transfer station, sending all messages to the same destination. It can 
>> translate one message into another, or simply “swallow” some messages so 
>> there’s no response and no error. A forwardInvocation: method can also 
>> consolidate several messages into a single response. What 
>> forwardInvocation:does is up to the implementor. However, the opportunity it 
>> provides for linking objects in a forwarding chain opens up possibilities 
>> for program design.
> 
> Alternatively and more simply, it seems, you could return nil from 
> ‘forwardingTargetForSelector:’.
> 


Hmmm. Unfortunately neither of these seem to do the trick.

First, -forwardingTargetForSelector: appears to return nil by default, so 
returning nil for that particular case doesn't do anything special.

So, adding to the triumvirate of the other mechanism, I'm still getting the 
doesNotRecogniseSelector exception. Here's what I've done:

- (BOOL)                                respondsToSelector:(SEL) aSelector
{
        if( aSelector == @selector(_processEndOfEventNotification:))
                return YES;
... [other code]

}


- (NSMethodSignature*)  methodSignatureForSelector:(SEL) aSelector
{
        if( aSelector == @selector(_processEndOfEventNotification:))
                return [NSMethodSignature methodSignatureForSelector:aSelector];
...[other code]
}

- (void)                                forwardInvocation:(NSInvocation*) 
invocation
{
        if([invocation selector] == @selector(_processEndOfEventNotification:))
                return;
...[other code]
}


The [other code] stuff is because as an undo manager these methods are also 
used for capturing the invocations from client code when the UM is used in 
non-proxy mode.

I'm fairly familiar with the -forwardInvocation: mechanism as I've used it here 
in GCUndoManager and in other code as a general forwarding solution, so unless 
I'm just being particularly dense today, it looks like that should work. And 
yet it doesn't, so I'm missing someting here.

--Graham



_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to