Cannot convert (NSError)-> Void in Swift 3

958 Views Asked by At

Hey guys so I recently updated my Xcode version to Xcode 8 and I have started getting these errors in the new betas that I haven't gotten before.

        CSSearchableIndex.default().indexSearchableItems([searchableItem]) { // Error.

        (error : NSError?) -> Void in

        if error != nil {

            print(error?.localizedDescription)
        }
    }

Here's the error : enter image description here

1

There are 1 best solutions below

1
On BEST ANSWER

Rather than NSError, use Error. Or, let the compiler infer this for you.

CSSearchableIndex.default().indexSearchableItems([searchableItem]) { error in
    if error != nil {
        print(error!.localizedDescription)
    }
}