How can I interact with functions in swift that used to take sized C arrays?
I read through Interacting with C APIS and still can't figure this out.
The documentation for the coords parameter of func getCoordinates(_ coords:UnsafeMutablePointer<CLLocationCoordinate2D>,range range: NSRange)
states: "On input, you must provide a C array of structures large enough to hold the desired number of coordinates. On output, this structure contains the requested coordinate data."
I tried several things, most recently:
var coordinates: UnsafeMutablePointer<CLLocationCoordinate2D> = nil
polyline.getCoordinates(&coordinates, range: NSMakeRange(0, polyline.pointCount))
Would I have to use something like:
var coordinates = UnsafeMutablePointer<CLLocationCoordinate2D>(calloc(1, UInt(polyline.pointCount)))
Pulling my hair out here... any thoughts?
var coordinates = UnsafeMutablePointer<CLLocationCoordinate2D>()
? – Speller'UnsafeMutablePointer<CLLocationCoordinate2D>' is not identical to 'CLLocationCoordinate2D'
Which really doesn't make any sense to me since it should beUnsafeMutablePointer<CLLocationCoordinate2D>'
in the function as well. – Dramavar coordinates = [CLLocationCoordinate2D]()
, but thegetCoordinates
function returns nothing to&coordinates
– Drama