示例工程 19-arc-memory-management

19-arc-memory-management/Sources/Ch19Crash/App.swift

swift · 0.3 KB

import Ch19Kit
import Foundation
 
@main
struct Ch19Crash {
    static func main() {
        var owner: Owner? = Owner(name: "gone")
        let child = UnownedChild(owner: owner!)
        owner = nil
 
        FileHandle.standardError.write(Data("about to touch unowned\n".utf8))
        print(child.ownerName)
    }
}