ã¯ããã« Swiftã®ã¨ã©ã¼å¦çã«ã¤ãã¦åå¿è ãªããè¨è¿°æ¹æ³ãæ´çãã¦ã¿ã¾ãã æ¬è¨äºã¯Swift 4.0ã«å¯¾å¿ãã¦ãã¾ãã ã¨ã©ã¼å¦çã¨ã¯ 以ä¸ã®ããã«ã¡ã½ããã§ä½ããã®ã¨ã©ã¼ãçºçããå ´åã«å¼ã³åºãå ã¸ã¨ã©ã¼ã¨ãã¦è¿ããã¨ãã§ãã¾ãã // ã¨ã©ã¼ãæã¤ã¡ã½ãã func methodA(text: String) throws { if text.isEmpty { throw NSError(domain: "errorã¡ãã»ã¼ã¸", code: -1, userInfo: nil) } print(text) } // å¼ã³åºãå ã¡ã½ãã func method() { do { try? methodA(text: "") } catch { // ã¨ã©ã¼å¦ç } } ãããã³ã«Error ä¸è¨ã®ä¾ã§ã¯NSErrorãã¨ã©ã¼ã¨ãã¾ããããããã¯NSErrorãErrorãããã³
{{#tags}}- {{label}}
{{/tags}}