I'm confused. Here is my code:
public func udpSocket(sock: GCDAsyncUdpSocket!, didReceiveData data: NSData!, fromAddress address: NSData!, withFilterContext filterContext: AnyObject!) {
var send_port : UnsafeMutablePointer<UInt16>
var hostPtr : AutoreleasingUnsafeMutablePointer<NSString?>
// This appears to be a class level function - not an individual function attached to the sock variable
GCDAsyncUdpSocket.getHost(&hostPtr, port: &send_port, fromAddress: address)
}
Here is my error:
Cannot invoke 'getHost' with an argument list of type '(inout AutoreleasingUnsafeMutablePointer, port: inout UnsafeMutablePointer, fromAddress: NSData!)'
And here is the "prototype"
class func getHost(hostPtr: AutoreleasingUnsafeMutablePointer<NSString?>, port portPtr: UnsafeMutablePointer<UInt16>, fromAddress address: NSData!) -> Bool
class func getHost(hostPtr: AutoreleasingUnsafeMutablePointer<NSString?>, port portPtr: UnsafeMutablePointer<UInt16>, family afPtr: UnsafeMutablePointer<Int32>, fromAddress address: NSData!) -> Bool
To me that looks like you pass in:
AutoreleasingUnsafeMutablePointer<NSString?>
and a
UnsafeMutablePointer<UInt16>
which I thought I did.
Any ideas where I went wrong?
You have to define the variables as
var send_port : UInt16 = 0
var hostPtr : NSString? = nil
With &
the variables are passed as an inout-argument to the function
taking the corresponding UnsafeMutablePointer
parameters.