Declaration of ‘objc_property_t’ must be imported from module ‘ObjectiveC.runtime’ before it is required
如果提示这个错误信息,加头文件#import <objc/runtime.h>[……]
Declaration of ‘objc_property_t’ must be imported from module ‘ObjectiveC.runtime’ before it is required
如果提示这个错误信息,加头文件#import <objc/runtime.h>[……]
1、iOS7及以后的版本中提供了JavaScriptSore框架,极大的方便了OC与JS的交互
2、基本使用参考: Object-C与JavaScript交互的两种方式
3、使用过程中存在一些问题,这里拿两个最为常见的问题进行分析
4.1、如果没有JS调用时没有该方法,如果捕获异常
A、JS调用OC方法时,如果不存在该方法不会造成程序崩溃,只是没任何反应而已,哪里可以看出来呢?
B、其实JSContext已经提供了一个方法,只是平时没有用,JSContext有条属性
1 2 3 4 5 6 7 8 9 10 11 | /*! @property @discussion If a call to an API function results in an uncaught JavaScript exception, the <code>exceptionHandler</code> block will be invoked. The default implementation for the exception handler will store the exception to the exception property on context. As a consequence the default behaviour is for unhandled exceptions occurring within a callback from JavaScript to be rethrown upon return. Setting this value to nil will result in all uncaught exceptions thrown from the API being silently consumed. */ @property (copy) void(^exceptionHandler)(JSContext *context, JSValue *exception); |
[……]
1、在iOS项目开发中,原生页面中掺杂Html5页面已不是什么新鲜事了,毕竟H5也他相关的优势,比如布局、富文本内容展示等;
2、随着H5页面的侵入,OC与JS的交互意愿越来越强烈,就目前来看,在不引用第三方库的前提下,有两种方式可以解决;
2.1、iOS6及以前通过拦截NSRequest请求来调用原生方法进行交互;
2.2、iOS7及以后的版本苹果官方引入了JavaScriptCore框架;
3、拦截NSRequest请求
A、UIwebView有个代理方法:
1 | - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType; |
B、此方法通过返回YES/NO来决定是否跳转到request的页面,因此我们可以通过协议头来区分是正常的URL请求还是本地方法的调用请求;[……]
1、基本分析
1.1、数组有两种形式,NSArray和NSMutableArray;
1.2、拷贝也有两个方法copy和mutableCopy;
1.3、那么相互组合就会有四种情况:NSArray的copy、mutableCopy;NSMutableArray的copy、mutableCopy;
2、代码验证
2.1、先创建一个NSObject对象与一个NSArray数组,将对象放到数组中;
2.2、分别对NSArray数组进行copy与mutableCopy,查看得到的结果数据类型及地址[……]
1. 在App Store安装xcode,最新版位6.0
2. 安装node.js环境
点击【install】,会下载mac的安装包。正常安装即可
3. 使用命令行安装 cordova
命令行帮助: http://cordova.apache.org/docs/en/4.0.0//guide_cli_index.md.html#The%20Command-Line%20Interface
主要命令: sudo npm install -g cordova[……]