How to set CMutablePointer<ObjCBool> to false in Swift?
This is the equivalent of *stop = YES;
:
stop.withUnsafePointer { $0.memory = true }
To make it more succinct, you could do things like:
operator infix <- {}
@infix func <- <T>(ptr: CMutablePointer<T>, value: T) {
ptr.withUnsafePointer { $0.memory = value }
}
and then the line above becomes simply this:
stop <- true
Not sure if that's recommended style, though...
(You can choose characters from / = - + * % < > ! & | ^ . ~
to create custom operators.)
As of Xcode 6 beta 4, you can now do:
stop.memory = true
Or, as holex noted, you can:
stop.initialize(true)