Skip to content

Instantly share code, notes, and snippets.

@iThinker
Created July 11, 2017 16:24
Show Gist options
  • Save iThinker/55cdf222ff0e663538319610e99d98be to your computer and use it in GitHub Desktop.
Save iThinker/55cdf222ff0e663538319610e99d98be to your computer and use it in GitHub Desktop.
func performWithErrorPointer<T>(_ executable: @autoclosure @escaping () throws -> T, _ errorPointer: NSErrorPointer) -> T? {
do {
return try executable()
}
catch let error {
errorPointer?.pointee = error as NSError
return nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment