I want to check if a NSURLErrorCancelled
occurred. So basically mapping this SO answer to C#.
The only thing I came up with is checking the error code directly:
if(e.Error.Code != -999){
// real error here
}
How can I compare the NSError
with NSURLError.Cancelled
in case the error code changes sometime?
Solution linked by David Karlaš:
var urlError = default(NSUrlError);
if(!Enum.TryParse<NSUrlError>(e.Error.Code.ToString(), out urlError)){
urlError = NSUrlError.Unknown;
}
// this is error code -999
if(urlError != NSUrlError.Cancelled){
// do something
}