FrozenHeart
FrozenHeart

Reputation: 20756

What is the best way to construct NSError object by myself in Swift

What is the best way to construct NSError object by myself in Swift? Is it ok to do it at all? I need to pass it to the some delegate function then.

Thanks in advance.

Upvotes: 4

Views: 2273

Answers (1)

Giordano Scalzo
Giordano Scalzo

Reputation: 6342

You can user the constructor of NSError:

let ERROR_CODE = 101
let error = NSError(domain: "my.domain.error", code: ERROR_CODE, userInfo: nil)

Upvotes: 8

Related Questions