obj_msgSend函数指针崩溃时,建立与64位arm64 [英] obj_msgSend function pointer crash when build with 64bit arm64

查看:501
本文介绍了obj_msgSend函数指针崩溃时,建立与64位arm64的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其实我原来的code的伟大工程,以X code 5.0.2,也非常适合发送给App Store的是:

Actually my original code works great with Xcode 5.0.2 and also great for sending to App Store which is:

objc_msgSend(self.target, self.successAction, category);

这行导致崩溃,X code5.1 beta5的。我发现了一个解决方案,以修复崩溃的: <一href="http://stackoverflow.com/questions/19507456/sudzc-arc-version-objc-msgsend-call-causes-exc-bad-access-using-64-bit-archite">SudzC ARC版 - objc_msgSend调用导致EXC_BAD_ACCESS采用64位架构

This line causes crashes with Xcode5.1 beta5. I found a solution to fix the crash: SudzC ARC version - objc_msgSend call causes EXC_BAD_ACCESS using 64-bit architecture

// solution
id (*response)(id, SEL, id) = (id (*)(id, SEL, id)) objc_msgSend;
response(self.target, self.successAction, category);

和我在使用了推荐的解决方案得到一点问题都没有或者使用X code 5或X code5.1beta来测试设备(iPhone 5S)或模拟器(32位或64位)。在构建设置的架构设置是在X code 5和标准体系结构(ARMv7的,armv7s,arm64)。

And I get no problem at all either using Xcode 5 or Xcode5.1beta to test on devices(iPhone 5s) or simulator(32bit or 64bit) when using the recommended solution. The architectures setting in Build Settings is "Standard architectures (armv7, armv7s)" in Xcode 5 and "Standard architectures (armv7, armv7s, arm64)".

不过,我的新的应用程序版本是准备今天出售的应用程序商店。而且它崩溃的每个设备上(iPhone 5S,5,4S)安装(根据Crashlytics报告)。 因为我没有用X code获取崩溃(建于真实设备),我不知道如果我解决问题,或由苹果公司以前没有审核。

However, my new version of app is ready for sale on App Store today. And it crashes on every devices(iPhone 5s, 5, 4s) installed (according to Crashlytics report). Since I don't get the crash using Xcode(build to real device), I don't know if I fix the problem or not before reviewed by Apple.

推荐答案

最后,我可以重现崩溃现在。只需编辑生成计划,改变运行YOURAPPNAME.app从调试到释放。

Finally, I can reproduce the crash right now. Simply edit Build Scheme and change "Run YOURAPPNAME.app" from Debug to Release.

和之后我可以重现这个错误,我知道如何解决它。由于我选择的功能类型为void(不返回任何东西),我不应该只是复制的问题呢(使用ID)是什么。

And right after I can reproduce this bug, I know how to fix it. Since my selector function type is void(does not return anything), I should not just copy what the question does (using "id").

通过更改:

id (*response)(id, SEL, id) = (id (*)(id, SEL, id)) objc_msgSend;
response(self.target, self.successAction, category);

要:

void (*response)(id, SEL, id) = (void (*)(id, SEL, id)) objc_msgSend;
response(self.target, self.successAction, category);

它修复!或者单行code感谢这个承诺在github

((void(*)(id, SEL, id))objc_msgSend)(self.target, self.successAction, category);

这篇关于obj_msgSend函数指针崩溃时,建立与64位arm64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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