相关疑难解决方法(0)

在swift NSObject子类中使用CoreFoundation对象时出现运行时错误

这是一个非常简单的类(子类NSObject),它保存一个CGPath对象列表并将一个附加CGPath到数组上init:

import Foundation
class MyClass: NSObject {

    var list = [CGPath]();

    init() {
        list.append(CGPathCreateMutable());
    }
}
Run Code Online (Sandbox Code Playgroud)

尝试使用此类时:

var instance = MyClass();
println(instance.list.count); // runtime error after adding this line
Run Code Online (Sandbox Code Playgroud)

产生一个丑陋的崩溃:

Playground execution failed: error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0).
The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.
* thread #1: tid = 0x1251d1, 0x00000001064ce069 …
Run Code Online (Sandbox Code Playgroud)

arrays nsobject ios swift

6
推荐指数
1
解决办法
2387
查看次数

标签 统计

arrays ×1

ios ×1

nsobject ×1

swift ×1