CocoaPods 里的 objc_msgSend
2015-06-12 09:59
239 查看
编译一个用到 QuickDialog 的项目,报 "Too Many arguments to function call, expected 0, have 3" 错。
根据 "https://developer.apple.com/library/ios/documentation/General/Conceptual/CocoaTouch64BitGuide/ConvertingYourAppto64-Bit/ConvertingYourAppto64-Bit.html", 倒是简单,只要强制转换成合适的函数原型就可以用了:
int (*action)(id, SEL, int) = (int (*)(id, SEL, int)) objc_msgSend;
不过呢,调用代码是在 pod 项目里,已经锁定不可修改,即使打开锁定,下回刷新pod一下,修改会被冲掉的。
看一眼 objc/message.h ,这是个保护措施,真正的函数原型在 OBJC_OLD_DISPATCH_PROTOTYPES 宏底下。然后就发现了这:
![](http://blog.freecoder.org/wp-content/uploads/2015/06/Screen-Shot-2015-06-12-at-9.27.25-AM-300x59.png)
在 pod 项目的 QuickDialog 目标上关掉 "Enable Strict Checking of objc_msgSend Calls" ,搞定。
根据 "https://developer.apple.com/library/ios/documentation/General/Conceptual/CocoaTouch64BitGuide/ConvertingYourAppto64-Bit/ConvertingYourAppto64-Bit.html", 倒是简单,只要强制转换成合适的函数原型就可以用了:
int (*action)(id, SEL, int) = (int (*)(id, SEL, int)) objc_msgSend;
不过呢,调用代码是在 pod 项目里,已经锁定不可修改,即使打开锁定,下回刷新pod一下,修改会被冲掉的。
看一眼 objc/message.h ,这是个保护措施,真正的函数原型在 OBJC_OLD_DISPATCH_PROTOTYPES 宏底下。然后就发现了这:
![](http://blog.freecoder.org/wp-content/uploads/2015/06/Screen-Shot-2015-06-12-at-9.27.25-AM-300x59.png)
在 pod 项目的 QuickDialog 目标上关掉 "Enable Strict Checking of objc_msgSend Calls" ,搞定。
相关文章推荐
- 开源框架 KJFrameForAndroid
- Sass浅谈
- html 多选 select option 插件 multiselect 使用
- opencv MAT数据操作
- Freeplane快速上手笔记
- 学编程的重要性,你值得思考
- ASP.NET 预编译
- 7-5匹配颜色
- [D-VII] (数)晶体管2逻辑门2寄存器s
- Redhat6.4静默安装Oracle11g
- 【转】分布式与集群的区别
- 加入购物车动画效果
- 7-4暗调/高光
- SELinux 学习笔记
- 数据结构系列之平衡树(数组构建法)
- Python2中的raw_input() 与 input()
- SSH架构BaseDao实现
- Technical help article describing SPV within MultiBit
- Matlab拟合曲线之幂律分布
- Jquery-input获取单选框选择的按钮