首页 > 解决方案 > 类型'NSError'在swift 4中没有成员'errorWith'?

问题描述

在以下行:

  completionHandler(Result.failure(NSError.errorWith(text: "Can't download video")))

我得到:

类型“NSError”没有成员“errorWith”

当前的替代方案是什么?

标签: iosswift

解决方案


它只是意味着NSError没有 errorWith 方法。如果你想创建NSError任何描述,试试这个

let error = NSError(domain: "SomeErrorDomain", code: -2001 /* some error code */, userInfo: ["description": "Can't download video"])

推荐阅读