ZhangChn
ZhangChn

Reputation: 3184

How to detect if a dyld-ed symbol exists?

Is there a common way to detect if a symbol exists or not? Like CGPathCreateCopyByStrokingPath() in iOS5, which is only available on iOS5 and later. If I compile and run apps using this routine on iOS 4 devices, I would get a runtime dyld error.

In Objective-C, +class and other utility APIs can be used to determine the existence of some class or some selector, is there any API to do this on dyld-ed symbols?

Or is it under Apple's permission to use dyld functions for an AppStore oriented app?

Upvotes: 0

Views: 689

Answers (1)

Alastair Stuart
Alastair Stuart

Reputation: 4185

To check the availability of a function, explicitly compare its address to NULL or nil.

if (CGPathCreateCopyByStrokingPath != NULL) {
    // it exists
}

Here's Apple's documentation on the matter (listing 3-2).

Upvotes: 4

Related Questions