这是一个非常简单的类(子类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)