美文网首页
关于Swift

关于Swift

作者: 未知的远方 | 来源:发表于2017-04-25 19:32 被阅读10次

    错误集锦
    1,Call can throw, but it is not marked with 'try' and the error is not handled


    1

    // 原因就是没有处理错误 。我们根据错误提示,调用可以抛出,但它没有标记和错误处理通过加一个try解决。
    // (PS: 就像Java中的异常错误处理,也是采用 try ...catch)

                do {
                    try listenSocket.accept(onPort: UInt16(port))
                } catch let error as NSError {
                    print("\(error.description)")
                }
    

    @http://www.jianshu.com/p/b30d8f72e722

    相关文章

      网友评论

          本文标题:关于Swift

          本文链接:https://www.haomeiwen.com/subject/zphfzttx.html