我正在尝试使用
Swift 2.0 try-catch.
override func viewDidLoad() { var obj : Object?; Hi( obj ); }
func Hi( open : Open? ) -> Open? { open!.Hi(); <-- here is error point. Fatal error ! print( "OK" ); return open; }
因此我将viewDidLoad()中的代码更改为:@H_502_3@
override func viewDidLoad() { try { var obj : Object?; Hi( obj ); } catch { print( "bug !!!" ); <- I want to this !!! } }
但它不起作用!@H_502_3@
我猜swift的try-catch与C,C#不同.@H_502_3@
func Hi( open : Open? ) -> Open? { if let op = open { op.Hi(); print( "OK" ); return open; } else { return nil; } }