js oc与线程
分属不同的线程
//定义需要暴露给js的内容,这里我们只暴露personName和queryPersonName接口
@protocol PersonProtocol <JSExport>
@property(nonatomic,copy)NSString *personName;
-(NSString *)queryPersonName;
@end
//Person实现PersonProtocol协议,而自己定义的age和queryPersonAge接口不暴露给js
@interface Person : NSObject <PersonProtocol>
@property(nonatomic,assign)NSInteger age;
-(NSInteger)queryPersonAge;
@end
@implementation Person
@synthesize personName = _personName;
-(NSString *)queryPersonName{
return self.personName;
}
-(NSInteger)queryPersonAge{
return self.age;
}
@end
-(void)refreshXX
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"info" ofType:@"html"];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]];
[self.webView loadRequest:request];
JSContext *jsContext = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
Person *person=[Person new];
person.personName = @"Greg";
person.age = 27;
jsContext[@"person"]=person;
}
<div data-role="collapsible">
<h3 onclick="person.queryPersonName()">systemVersion</h3>
<p id="systemVersion"></p>
</div>
(lldb) bt
* thread #1: tid = 0x16b9e9, 0x000000010d5c1d40 jsTest`-[ViewController refreshXX](self=0x00007ff12a60ea30, _cmd="refreshXX") + 16 at ViewController.m:63, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
* frame #0: 0x000000010d5c1d40 jsTest`-[ViewController refreshXX](self=0x00007ff12a60ea30, _cmd="refreshXX") + 16 at ViewController.m:63
frame #1: 0x000000010eb4ea8d UIKit`-[UIApplication sendAction:to:from:forEvent:] + 92
frame #2: 0x000000010ecc1e67 UIKit`-[UIControl sendAction:to:forEvent:] + 67
frame #3: 0x000000010ecc2143 UIKit`-[UIControl _sendActionsForEvents:withEvent:] + 327
frame #4: 0x000000010ecc1263 UIKit`-[UIControl touchesEnded:withEvent:] + 601
frame #5: 0x000000010ebc199f UIKit`-[UIWindow _sendTouchesForEvent:] + 835
frame #6: 0x000000010ebc26d4 UIKit`-[UIWindow sendEvent:] + 865
frame #7: 0x000000010eb6ddc6 UIKit`-[UIApplication sendEvent:] + 263
frame #8: 0x000000010eb47553 UIKit`_UIApplicationHandleEventQueue + 6660
frame #9: 0x000000010e6bb301 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
frame #10: 0x000000010e6b122c CoreFoundation`__CFRunLoopDoSources0 + 556
frame #11: 0x000000010e6b06e3 CoreFoundation`__CFRunLoopRun + 867
frame #12: 0x000000010e6b00f8 CoreFoundation`CFRunLoopRunSpecific + 488
frame #13: 0x0000000112051ad2 GraphicsServices`GSEventRunModal + 161
frame #14: 0x000000010eb4cf09 UIKit`UIApplicationMain + 171
frame #15: 0x000000010d5c277f jsTest`main(argc=1, argv=0x00007fff5263e680) + 111 at main.m:14
frame #16: 0x00000001105b292d libdyld.dylib`start + 1
2017-04-07 14:50:16.620 jsTest[31840:1489385] /Users/zzf073/Library/Developer/CoreSimulator/Devices/96C38E7B-35FF-49AC-80A1-BCAA1E8E7873/data/Containers/Bundle/Application/AFCD9E1B-D5FD-498E-8AD5-AEDFC672314F/jsTest.app/info.html
(lldb) bt
* thread #8: tid = 0x16ba34, 0x000000010d5c1770 jsTest`-[Person queryPersonName](self=0x00007ff12a61ca20, _cmd="queryPersonName") + 16 at ViewController.m:28, name = 'WebThread', stop reason = breakpoint 1.1
* frame #0: 0x000000010d5c1770 jsTest`-[Person queryPersonName](self=0x00007ff12a61ca20, _cmd="queryPersonName") + 16 at ViewController.m:28
frame #1: 0x000000010e67e5cc CoreFoundation`__invoking___ + 140
frame #2: 0x000000010e67e41e CoreFoundation`-[NSInvocation invoke] + 286
frame #3: 0x000000010da38db3 JavaScriptCore`JSC::ObjCCallbackFunctionImpl::call(JSContext*, OpaqueJSValue*, unsigned long, OpaqueJSValue const* const*, OpaqueJSValue const**) + 451
frame #4: 0x000000010da38926 JavaScriptCore`JSC::objCCallbackFunctionCallAsFunction(OpaqueJSContext const*, OpaqueJSValue*, OpaqueJSValue*, unsigned long, OpaqueJSValue const* const*, OpaqueJSValue const**) + 262
frame #5: 0x000000010da39bad JavaScriptCore`long long JSC::APICallbackFunction::call<JSC::ObjCCallbackFunction>(JSC::ExecState*) + 573
frame #6: 0x000000010da03340 JavaScriptCore`JSC::LLInt::setUpCall(JSC::ExecState*, JSC::Instruction*, JSC::CodeSpecializationKind, JSC::JSValue, JSC::LLIntCallLinkInfo*) + 528
frame #7: 0x000000010da0a35d JavaScriptCore`llint_entry + 22900
frame #8: 0x000000010da047d9 JavaScriptCore`vmEntryToJavaScript + 326
frame #9: 0x000000010d8d6959 JavaScriptCore`JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 169
frame #10: 0x000000010d8bd5ad JavaScriptCore`JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 493
frame #11: 0x000000010d691bd7 JavaScriptCore`JSC::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&, WTF::NakedPtr<JSC::Exception>&) + 71
frame #12: 0x000000011395fc1a WebCore`WebCore::JSEventListener::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) + 1002
frame #13: 0x00000001135ac630 WebCore`WebCore::EventTarget::fireEventListeners(WebCore::Event*, WebCore::EventTargetData*, WTF::Vector<WebCore::RegisteredEventListener, 1ul, WTF::CrashOnOverflow, 16ul>&) + 752
frame #14: 0x00000001135ac267 WebCore`WebCore::EventTarget::fireEventListeners(WebCore::Event*) + 311
frame #15: 0x000000011359550e WebCore`WebCore::MouseOrFocusEventContext::handleLocalEvents(WebCore::Event&) const + 174
frame #16: 0x00000001135960b8 WebCore`WebCore::EventDispatcher::dispatchEvent(WebCore::Node*, WTF::PassRefPtr<WebCore::Event>) + 920
frame #17: 0x0000000113c97c5d WebCore`WebCore::Node::dispatchEvent(WTF::PassRefPtr<WebCore::Event>) + 29
frame #18: 0x000000011357f61e WebCore`WebCore::Element::dispatchMouseEvent(WebCore::PlatformMouseEvent const&, WTF::AtomicString const&, int, WebCore::Element*) + 318
frame #19: 0x000000011359c8df WebCore`WebCore::EventHandler::dispatchMouseEvent(WTF::AtomicString const&, WebCore::Node*, bool, int, WebCore::PlatformMouseEvent const&, bool) + 111
frame #20: 0x000000011359e108 WebCore`WebCore::EventHandler::handleMouseReleaseEvent(WebCore::PlatformMouseEvent const&) + 1192
frame #21: 0x00000001135a550d WebCore`WebCore::EventHandler::mouseUp(WebEvent*) + 237
frame #22: 0x000000011310cbe3 WebKitLegacy`-[WebHTMLView mouseUp:] + 115
frame #23: 0x000000011414c30d WebCore`-[WAKView _selfHandleEvent:] + 125
frame #24: 0x000000011414c26f WebCore`-[WAKView handleEvent:] + 63
frame #25: 0x000000011414f46d WebCore`-[WAKWindow sendEventSynchronously:] + 269
frame #26: 0x000000010ee6ce81 UIKit`__47-[UIWebDocumentView(Interaction) performClick:]_block_invoke + 740
frame #27: 0x000000010ee6cb97 UIKit`-[UIWebDocumentView(Interaction) performClick:] + 68
frame #28: 0x000000010ee6d49f UIKit`__64-[UIWebDocumentView(Interaction) _sendMouseMoveAndAttemptClick:]_block_invoke + 345
frame #29: 0x0000000114167996 WebCore`HandleRunSource(void*) + 390
frame #30: 0x000000010e6bb301 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
frame #31: 0x000000010e6b11a7 CoreFoundation`__CFRunLoopDoSources0 + 423
frame #32: 0x000000010e6b06e3 CoreFoundation`__CFRunLoopRun + 867
frame #33: 0x000000010e6b00f8 CoreFoundation`CFRunLoopRunSpecific + 488
frame #34: 0x0000000114167325 WebCore`RunWebThread(void*) + 469
frame #35: 0x00000001108d199d libsystem_pthread.dylib`_pthread_body + 131
frame #36: 0x00000001108d191a libsystem_pthread.dylib`_pthread_start + 168
frame #37: 0x00000001108cf351 libsystem_pthread.dylib`thread_start + 13
js oc与线程的更多相关文章
- iOS js oc相互调用JavaScriptCore(一)
原址:http://blog.csdn.net/lwjok2007/article/details/47058101 1.普通调用 从iOS7开始 苹果公布了JavaScriptCore.framew ...
- 转载 OS js oc相互调用(JavaScriptCore) ---js调用iOS ---js里面直接调用方法
OS js oc相互调用(JavaScriptCore) 接着上节我们讲到的iOS调用js 下来我们使用js调用iOS js调用iOS分两种情况 一,js里面直接调用方法 二,js里面通过对象调用 ...
- 转载 iOS js oc相互调用(JavaScriptCore) --iOS调用js
iOS js oc相互调用(JavaScriptCore) 从iOS7开始 苹果公布了JavaScriptCore.framework 它使得JS与OC的交互更加方便了. 下面我们就简单了解一下这 ...
- js运行机制(线程)
浏览器线程 js运作在浏览器中,是单线程的,即js代码始终在一个线程上执行,这个线程称为js引擎线程. 浏览器是多线程的,除了js引擎线程,它还有: UI渲染线程 浏览器事件触发线程 http请求线 ...
- 深入理解 Node.js 进程与线程
原文链接: https://mp.weixin.qq.com/s?__biz=MzAxODE2MjM1MA==&mid=2651557398&idx=1&sn=1fb991da ...
- WKWebView与Js (OC版)
OC如何给JS注入对象及JS如何给IOS发送数据 JS调用alert.confirm.prompt时,不采用JS原生提示,而是使用iOS原生来实现 如何监听web内容加载进度.是否加载完成 如何处理去 ...
- iOS js oc相互调用(JavaScriptCore)(二)
下来我们使用js调用iOS js调用iOS分两种情况 一,js里面直接调用方法 二,js里面通过对象调用方法 首先我们看第一种,直接调用方法. 其中用到了iOS的block 上代码 -(void)we ...
- UIWebView 获取当前的javascript上下文,并js,oc互调
OC调用UIWebView 中的js,网上例子很多,最常用的是UIWebView自带的一个方法: - (NSString *)stringByEvaluatingJavaScriptFromStrin ...
- iOS js oc相互调用(JavaScriptCore 下)
下来我们使用js调用iOS js调用iOS分两种情况 一,js里面直接调用方法 二,js里面通过对象调用方法 首先我们看第一种,直接调用方法. 其中用到了iOS的block 上代码 -(void)we ...
随机推荐
- 16、IO (Properties、序列化流、打印流、CommonsIO)
Properties集合的特点 * A: Properties集合的特点 * a: Properties类介绍 * Properties 类表示了一个持久的属性集.Properties 可保存在流中或 ...
- layui——上传图片,并实现放大预览
一般上传文件后会返回文件的路径,然后存储到数据库,那么首先实现上传后的放大和删除功能 function uploadSmallPic() { var upload = layui.upload; up ...
- JAVA工具系列之——Postman
1 概述 Postman是一款测试rest接口的工具,可以实现前端未实施的情况下,后端同步开发.本文从部署到运用进行展开描写. 2 部署 第一步:进入Postman官网下载最新版本,下载链接 第二步: ...
- 借助 Filter 生成静态页面缓存问题
如果有些 jsp 页面,在一次 jsp 页面生成后 html 后, 就不太可能需要更新.可以使用缓存机制来解决这个问题. 解决思路如下 1. 定义一个文件夹 pagestaticize,用来存放 j ...
- poj 3070 Fibonacci 矩阵相乘
Fibonacci Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7715 Accepted: 5474 Descrip ...
- Vue指令的钩子函数使用方法
在Vue 中可以把一系列复杂的操作包装为一个指令. 什么是复杂的操作? 我的理解是:复杂逻辑功能的包装.违背数据驱动的 DOM 操作以及对一些 Hack 手段的掩盖等.我们总是期望以操作数据的形式来实 ...
- [HNOI2006]最短母串问题
题目大意:给定一个字符串集,求一个最短字串,使得该集合内的串都是该串的一个子串 算法:AC自动机+最短路+状压DP 注意空间限制 #include"cstdio" #include ...
- windows操作系统用命令提示符查看占用端口号的进程
在开发中有时我们需要确定哪个占用了8080端口,在windows命令行窗口下执行: 命令执行后打印出来的结果如下所示:
- 03.CSS选择器-->交集并集选择器
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- git分支无法获取
git 上新建的分支,本地想要拉取该分支,但是找不到这个分支 使用 git branch -a 也看不到该分支 使用命令: git checkout -b branch_nameA origin/ ...