Reputation: 571
I am working in iOS8 right now and I wanted to check if the CFType 'SecAccessControlRef' is available. Since the app will support iOS 7, without a check, the app will crash. For a regular NSClass I would just use a check like
if (NSClassFromString('SomeClass') == NULL)
but is there something similar for non NSClass items?
Upvotes: 1
Views: 155
Reputation: 53000
Rather than testing for the type itself you can test for one of the functions that support the type. When a framework is weak-linked the address of C functions will be NULL
if the framework is not present. For example you should be able to use something like:
BOOL isSecAccessControlRefAvailable = SecAccessControlCreateWithFlags != NULL;
See Using Weakly Linked Methods, Functions, and Symbols in Apple's SDK Compatibility Guide.
Upvotes: 4
Reputation: 8741
This isn't exactly what you want but I've used this for a similar type of question:
if (&kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly == NULL) {
return NO; // must be on iOS7
}
Upvotes: 0