Re: [Pyobjc-dev] NSUndoManager.prepareWithInvocationTarget_
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2002-12-30 20:07:27
|
On Monday, Dec 30, 2002, at 01:17 Europe/Amsterdam, David Eppstein wrote: > Should > NSUndoManager.prepareWithInvocationTarget_(x).some_Method_(arg,arg) > work (where x is any object and some_Method_ is a selector handled by > x)? I expected that this would work, but it clearly doesn't. This seems to be caused by a misunderstanding on my part of the semantics of 'NSObject.respondsToSelector:'. I expected that this returns true whenever 'NSObject.methodSignatureForSelector:' returns a non-nil value, but it doesn't. ----- test.py -------- from Foundation import * class Foo (NSObject): def test_(self, foo): print foo x = Foo.new() m = NSUndoManager.new() m.prepareWithInvocationTarget_(x) print x.respondsToSelector_('test:') # Prints 1 print m.respondsToSelector_('test:') # Prints 0? print x.methodSignatureForSelector_('test:') # Prints <NSMethodSignature ...> print m.methodSignatureForSelector_('test:') # Prints same value print m.methodSignatureForSelector_('foo:') # Raises AttributeError? m.test_("hello world") m.undo() ---- end of test.py ---- As I wrote earlier I expected 'm.respondsToSelector_('test:') to return 1. Because it doesn't the bridge assumes that 'm' won't respond to 'test_'. Fixing this design-error won't be too hard. I'm not yet sure why 'm.methodSignatureForSelector_("foo:")' raises an exception (it has nothing to do with the NSUndoManager class, 'x.methodSignatureForSelector_("foo:")' raises the same exception. Ronald |