How to pass an error pointer in the Swift language?

后端 未结 2 770
刺人心
刺人心 2021-02-06 20:14

I am attempting to pass an error pointer in swift and am unable to do so. The compiler complains that \"NSError is not convertible to \'NSErrorPointer\'\".

var e         


        
2条回答
  •  名媛妹妹
    2021-02-06 20:56

    This suggestion is up for discussion, but some engineers would prefer to use the golden path syntax:

    var maybeError: NSError?
    if let results = context.executeFetchRequest(request, error: &maybeError) {
        // Work with results
    } else if let error = maybeError {
        // Handle the error
    }
    

提交回复
热议问题