草庐IT

CFRunLoopTimerCreate

全部标签

Swift CFRunLoopTimerCreate - 如何在定时器回调中获取 "self"

在给定以下代码的情况下,如何访问类“self”实例以调用类实例方法。如果我尝试self.callSomeClassIntance(),如图所示,我会从编译器收到“无法从捕获上下文的闭包形成C函数指针”错误。我尝试使用info.callSomeClassInstance(),但这会给出“无成员callSomeClassInstance”错误。如果一行代码xxxx.callSomeClassIntance()被删除,代码将正确触发时间。importFoundationclassFoo{funccallSomeClassIntance(){}funcstart(){letrunLoop:CF