Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can NSString constants be weak linked?

Tags:

ios

Can NSString constants be weak linked? AVCaptureSessionPresetiFrame960x540 isn't defined prior to iOS 5. I avoid actually referencing it and it loads fine in gdb, but when I load an ipa, it seems to crash in dyld before ever invoking main.

The related question, Using Weakly Linked Framework's extern constants Crash, seems to say "no" and I've taken the same apporoach: using the string value directly.

like image 849
smparkes Avatar asked May 31 '12 16:05

smparkes


1 Answers

Constants can be weak linked too. To test if the constant is available you must check if it’s address is not NULL before you try to use it:

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

Note the & operator to take the address of the constant.

like image 94
Sven Avatar answered Oct 23 '22 12:10

Sven