I’m trying to set up an NSInputStream
and NSOutputStream
for a Bonjour connection on a NSNetService
. The getInputStream method requires arguments of the type UnsafeMutablePointer<NSInputStream?>
:
public func getInputStream(inputStream: UnsafeMutablePointer<NSInputStream?>, outputStream: UnsafeMutablePointer<NSOutputStream?>) -> Bool
But when I do this the inputStream and the outputStream stay nil and succes is false:
let inputStream:UnsafeMutablePointer<NSInputStream?> = nil
let outputStream:UnsafeMutablePointer<NSOutputStream?> = nil
var succes = service.getInputStream(inputStream, outputStream: outputStream)
Another problem is that I cannot approach it as an ‘NSInputStream’ because it of type ‘UnsafeMutablePointer,’. When I try this I get the following error:
Error:(52, 13) value of type 'UnsafeMutablePointer<NSInputStream?>' (aka 'UnsafeMutablePointer<Optional<NSInputStream>>') has no member 'delegate'
What is the right way to handle these mutable pointer types in swift? Any help would be greatly appreciated, thanks!