Skip to content

NSRunLoop ​

NSRunLoop 表示一个线程的事件循环。JS 运行在主线程上,能拿到的只有主线程的那一个,NSRunLoop.mainRunLoop。

它唯一的用处是作为 CADisplayLink.addToRunLoop() 的参数:CADisplayLink 加入它之后才开始工作。

继承关系:EventTarget → NSObject → NSRunLoop

构造函数 ​

不能用 new 创建。用 NSRunLoop.mainRunLoop。

静态属性 ​

NSRunLoop.mainRunLoop 只读

主线程的事件循环。

对应的 iOS API ​

ObjCJS
NSRunLoop.mainRunLoopNSRunLoop.mainRunLoop
NSRunLoop.currentRunLoopNSRunLoop.mainRunLoop。JS 在主线程上,两者是同一个

参见 ​