Comments (5)
不是很明白你说的这个是什么问题。你可以参考一下SwiftTimer的源代码,按照SwiftTimer的代码模式来使用就好。
from zen.
我只是在使用的时候,scheduleRepeating这个方法有好多个不同的参数配置。
其中就包括
这里的DispatchWallTime 应该也可以用到timer里吧, 但是我使用他的时候,他却不会执行timer。
请问你对DispatchWallTime使用过么? ios10 swift3.0
from zen.
我觉得有可能原因是你是在Playground上面运行的。Playground执行完一遍就结束进程了。你需要在Playground加上一句:PlaygroundPage.current.needsIndefiniteExecution = true
from zen.
原因我找到了。是因为我初始化timer的时候,没有初始化成一个全局变量,当方法执行过后,这个timer就被销毁了。也就不会调用定时器。
DispatchTime & dispatchWallTime 使用并无区别,只不过根据网上的说法是一个是相对时间,一个代表的是绝对时间。 就是dispatchTime可能会在特殊的情况下被挂起,但是无论任何情况dispatchWallTime都不会被挂起。
from zen.
嗯嗯。生命周期的问题。解决了就好。
from zen.
Related Issues (17)
- iOS夯实:ARC时代的内存管理中的[self someMethod]; HOT 1
- iOS夯实:ARC时代的内存管理 HOT 1
- 错字 找成内存泄漏 HOT 1
- SwiftTimer.deinit EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) HOT 2
- 对于 throttle 的使用场景存在疑问
- Swift学习: 从Objective-C到Swift中有误 HOT 2
- 网络相关 HOT 1
- 关于 swift 中的 atomic,苹果官方,给出了一个替代/模拟 atomic 的方案 HOT 1
- 关于像素重绘问题 HOT 9
- 看了RunLoop的文章,请教一个问题 HOT 1
- apple说的是不能在initialize方法里使用存取器吧,不是init方法吧 HOT 1
- 不懂就问,为何我这里增加target报错呢? HOT 1
- readonly,readwrie 直接通过声明变量var,声明常量let的方式来指明 HOT 1
- 图形性能离屏渲染 HOT 1
- 非常感谢! HOT 1
- 一处手误 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zen.