2014-06-25 48 views

回答

2

您應該能夠創造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

+0

謝謝@rickster –