0
我試着去畫線2之間協調的MKMapView我有把所有的POI陣列, 所以我有這樣的代碼如何斯威夫特CMutablePointer <MKMapPoint>設定值
var pointArr: CMutablePointer<MKMapPoint> = nil
,我的問題是如何將值添加到pointArr?
我試着去畫線2之間協調的MKMapView我有把所有的POI陣列, 所以我有這樣的代碼如何斯威夫特CMutablePointer <MKMapPoint>設定值
var pointArr: CMutablePointer<MKMapPoint> = nil
,我的問題是如何將值添加到pointArr?
您應該能夠創造MKMapPoint
秒的陣列,並分配給您的指針:
let lax = MKMapPointForCoordinate(CLLocation(latitude: 33.9424955, longitude: -118.4080684).coordinate)
let jfk = MKMapPointForCoordinate(CLLocation(latitude: 40.6397511, longitude: -73.7789256).coordinate)
var points: MKMapPoint[] = [lax, jfk]
let line = MKPolyline(points: &points, count: points.count)
注意,一個CMutablePointer
預計爲指向的東西可變 - 如果points
聲明瞭let
代替var
,將其分配給可變指針(或將其傳遞給可變指針參數)將不起作用。
有關詳細信息,請參閱Pointers in 使用Swift with Cocoa和Objective-C。
謝謝@rickster –