Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ios

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.

like image 867
FrozenHeart Avatar asked Mar 18 '23 19:03

FrozenHeart


1 Answers

You can user the constructor of NSError:

let ERROR_CODE = 101
let error = NSError(domain: "my.domain.error", code: ERROR_CODE, userInfo: nil)
like image 68
Giordano Scalzo Avatar answered Apr 25 '23 08:04

Giordano Scalzo