Can NSString constants be loosely coupled?

Can NSString constants be loosely coupled? AVCaptureSessionPresetiFrame960x540 not defined until iOS 5. I avoid referencing it and it loads fine in gdb, but when I load ipa it seems to crash into dyld before invoking main.

A related question is Using constants extern constants The loosely coupled Crash structure seems to say no, and I took the exact same apporoach: directly using a string value.

+7
source share
1 answer

Constants can also be weak. To check if a constant is available, you should check if its address is NULL before trying to use it:

 if (&AVCaptureSessionPresetiFrame960x540 != NULL) { // Constant is available and can be used } 

Pay attention to the & operator to accept the constant address.

+6
source

All Articles