NSString常量可以弱连接吗? [英] Can NSString constants be weak linked?

查看:93
本文介绍了NSString常量可以弱连接吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

NSString常量是否可以弱链接? AVCaptureSessionPresetiFrame960x540 未在iOS 5之前定义。我避免实际引用它并且它在gdb中加载正常,但是当我加载ipa时,它似乎在dyld之前崩溃调用main。

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.

相关问题,使用弱链接框架的外部常量Crash ,似乎说不,我采用相同的方法:直接使用字符串值。

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.

推荐答案

常量也可以弱连接。要测试常量是否可用,您必须在尝试使用它之前检查它的地址是否不是 NULL

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.

这篇关于NSString常量可以弱连接吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆