How to receive and use NSErrorPointer
nserror, swift
Solution
If you look into the headers you can see that `NSErrorPointer` is:
typealias NSErrorPointer = AutoreleasingUnsafePointer<NSError?>
Which is:
struct AutoreleasingUnsafePointer<T> : Equatable, LogicValue {
func getLogicValue() -> Bool
/// Access the underlying raw memory, getting and
/// setting values.
var memory: T
}
So you must check the logic value and then set memory, like this:
if error != nil {
error.memory = NSError(...)
}
Also mentioned here: Adopting Cocoa Design Patterns
Problem
I'm not asking how to pass an NSErrorPointer to a function, but rather how to receive it and use it. I couldn't find any documentation on this whatsoever. Something like this: ``` func doSomething(error: NSErrorPointer) { error = NSError(...); } ``` The code above gives Cannot assign to 'let' value 'error'