Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bbc6bae9/jscontext-timer-ios
JSContext支持window.setTimeout、window.setInterval
https://github.com/bbc6bae9/jscontext-timer-ios
Last synced: 28 days ago
JSON representation
JSContext支持window.setTimeout、window.setInterval
- Host: GitHub
- URL: https://github.com/bbc6bae9/jscontext-timer-ios
- Owner: BBC6BAE9
- Created: 2022-05-17T11:09:36.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-05-18T07:19:22.000Z (over 2 years ago)
- Last Synced: 2024-11-25T04:07:45.673Z (28 days ago)
- Language: Objective-C
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JSContext 支持window.setTimeout
参考1:https://developer.mozilla.org/en-US/docs/Web/API/setTimeout
参考2:https://developer.mozilla.org/en-US/docs/Web/API/setInterval
## JavaScript 调用参考
```javascript
nativeLog("开始计时");
var intervalId = setInterval(function(){nativeLog("客户端完成计时 setInterval 任务");}, 1000);
nativeLog(intervalId);
setTimeout(function(){nativeLog("客户端完成计时任务");clearInterval(intervalId);}, 3000);
```## Objective - C 参考
```objective-c
JSContext *ctx = [[JSContext alloc] init];
[ctx enableWindowTimer];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"demo" ofType:@"js"];
NSString *script = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
[ctx evaluateScript:script];
```