Re: [Pyobjc-dev] def respondsToSelector_(self, aSelector):
Brought to you by:
ronaldoussoren
|
From: Ronald O. <ron...@ma...> - 2007-11-11 12:59:17
|
On 11 Nov, 2007, at 9:48, Chris McClimans wrote:
> I've looked through the docs, but I can only guess I'm approaching
> this the wrong way as I work through Chapter 5 in Hillegass' Cocoa
> book via PyOjbc.
>
> If I want to do something that logs all calls to the
> respondsToSelector call to my class similar to this:
>
> - (BOOL)respondsToSelector:(SEL)aSelector
> {
> NSString *methodName = NSStringFromSelector(aSelector);
> NSLog(@"respondsToSelector:%@", methodName);
> return [super respondsToSelector:aSelector];
> }
>
> I would think I would implement something like this in PyObjc:
>
> class MyAppDelegate(NSObject):
> def respondsToSelector_(self, aSelector):
> NSLog('We Are Responding')
> return super(MyAppDelegate,self
> ).respondsToSelector_(self,aSelector)
>
> However I get a weird error about not being able to create IMP for
> instances of objc.native_selector:
>
> Traceback (most recent call last):
> File "/Volumes/Raid/mcclimans/MyApp/build/Release/MyApp.app/
> Contents/Resources/main.py", line 17, in <module>
> import TwiceAsTallAppDelegate
> File "/Volumes/Raid/mcclimans/MyApp/build/Release/MyApp.app/
> Contents/Resources/MyAppDelegate.py", line 12, in <module>
> class TwiceAsTallAppDelegate(NSObject):
> TypeError: Error when calling the metaclass bases
> Sorry, cannot create IMP for instances of type
> objc.native_selector
> 2007-11-11 01:36:53.971 MyApp[1227:10b] *** Terminating app due to
> uncaught exception 'NSInternalInconsistencyException', reason: '/
> Volumes/Raid/mcclimans/My/main.m:44 main() PyRun_SimpleFile failed
> with file '/Volumes/Raid/mcclimans/My/build/Release/MyApp.app/
> Contents/
> Resources/main.py'. See console for errors.'
> 2007-11-11 01:36:53.973 MyApp[1227:10b] Stack: (
> 2420150891,
> 2471022747,
> 2420150347,
> 2420150410
> )
>
> Any thought?
That's a bug in PyObjC. I haven't found the source of the bug yet,
and also don't have a workaround just yet.
Ronald
|