How to convert CGPoint in NSValue in swift?
Try something like that:
let point = CGPointMake(9, 9)
var pointObj = NSValue(CGPoint: point)
If you aren't planning on using the array in Objective-C, and can keep it as a Swift Array, then you don't need to turn the point into an NSValue, you can just add the point to the array directly:
let point1 = CGPoint(x: 9.0, y: 9.0)
let point2 = CGPoint(x: 10.0, y: 10.0)
let pointArray = [point1, point2] // pointArray is inferred to be of type [CGPoint]
let valuesArray = pointsArray as [NSValue]
Exactly as you'd imagine:
let point = CGPoint(x: 9.0, y: 9.0)
let pointObj = NSValue(CGPoint: point)
let newPoint = pointObj.CGPointValue()