Adventures in the transition from C to Cocoa.

Thursday, November 1, 2007

Best console log message ever

I was put between a rock and a hard place. Basically, I had to call a method on a class that isn't exported (i.e. I'm in plugin-space, and it needs to invoke something on an application-internal class that isn't exported). Through some trickery, I was able to get it working (man I love objective-C!). However, inserting the plugin into an application that doesn't have such a class results in an amazing console error that I've never seen before:


Nov 1 18:33:02 phendrana Photo Booth[33276]: *** NSInvocation: warning: object 0xfce0e0 of class 'specialInternalClass' does not implement methodSignatureForSelector: -- trouble ahead
Nov 1 18:33:02 phendrana Photo Booth[33276]: *** NSInvocation: warning: object 0xfce0e0 of class 'specialInternalClass' does not implement doesNotRecognizeSelector: -- abort


that "trouble ahead" part is awesome. I think it happens to any OC object that doesn't inherit from NSObject, but gets treated like it does. Fun stuff, that :)

6 comments:

Christopher Nehren said...

Thank you for posting this little tidbit. I was fiddling about with some command line ObjC and trying to copy some code I got building under GNUStep to my Mac. The GNUStep code had an object that derived from Object, rather than NSObject. Was getting these errors and the comment you made about changing it to derive from NSObject fixed the problem. So, thanks!

Muriel said...

Good for people to know.

Anonymous said...

sweet that worked thanks!

Anonymous said...

When you say that the offending object "gets treated" like a NSObject, what do you mean?

Anonymous said...

You made my day! Messed around with the same thing for quite a while. Thanks for sharing this!

pipeline said...

It does happen in one other place - if you happen to accidentally reuse a reserved Class name in the objc runtime.

Categories