Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

1. The Basics > 1.20. Determining Whether Instance or Class Methods Are Availab...

1.20. Determining Whether Instance or Class Methods Are Available

Problem

Your development SDK is the newest SDK, but you want to support devices running older iOS versions and APIs.

Solution

Use the instancesRespondToSelector: class method of NSObject to determine whether a specific selector exists in an instance of that class.

Note

A selector is the name of your method without the parameter data types. For instance, given the following method declaration:

- (BOOL) doesString:(NSString *)paramNeedle 
      existInString:(NSString *)paramHaystack;

The selector for this method would be doesString:existInString:.

To determine whether a class itself responds to a class method, use the respondsToSelector: class method of your class. You can use the same method on an instance of a class to determine whether that instance responds to an instance method, as well as the instancesRespondToSelector: class method of the NSObject class.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial