Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: respondsToSelector - #import OR compiler warnings?



On Dec 30, 2008, at 12:06 AM, Steve Cronin wrote:

Ken - I don't understand what you said about the method's signature's compliance with NSObject _protocol_.
I looked at the protocol definition in the documentation and I just don't understand well enough to see what I could do to "side-step" the warnings,
Would you be willing to spend another sentence or two on that?

Sure. Sorry if I was unclear.

First, I only underlined "protocol" to make sure you looked in the right place in the documentation. The -performSelector:... methods are documented as part of the NSObject protocol, not the NSObject class.

Second, the documentation for the -performSelector: method says the following:

The aSelector argument should identify a method that takes no arguments. For methods that return anything other than an object, useNSInvocation.

That's saying that the selector you pass to -performSelector: should be for a method which takes no arguments and returns an object pointer. This -- the number and types of arguments and return type -- is the "signature" of the method.


The -performSelector:withObject: and - performSelector:withObject:withObject: methods similarly describe the signature requirements for the method identified by the selector you pass.

So, if you are working with a selector for a method which matches the signature required by one of those methods, then you can safely use those methods. Doing so is a way to invoke the method without getting the compiler warning that was troubling you.

Cheers,
Ken

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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/email@hidden

This email sent to email@hidden
References: 
 >respondsToSelector - #import OR compiler warnings? (From: Steve Cronin <email@hidden>)
 >Re: respondsToSelector - #import OR compiler warnings? (From: Graham Cox <email@hidden>)
 >Re: respondsToSelector - #import OR compiler warnings? (From: Steve Cronin <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.