I would like to have a pointer as a class parameter. But when I try to encode init, I get this error:Cannot pass immutable value of type 'AnyObject?' as inout argument
class MyClass {
var valuePointer: UnsafeMutablePointer<AnyObject?>
init(value: inout AnyObject?) {
self.valuePointer = &value
}
}
I would like to create an instance of MyClass that can refer to the same "value". Then, when I edit this value in this class, it will change everywhere.
This is the first time I work with a pointer in Swift. I think I'm doing it wrong ...
source
share