As my question title says how can I convert CGPoint
into NSValues
so I can store then Into array In swift.
In objective-C we can do it like this:
// CGPoint converted to NSValue
CGPoint point = CGPointMake(9, 9);
NSValue *pointObj = [NSValue valueWithCGPoint:point];
But can anybody tell me that how can I do this in swift?
Thanks In Advance.
Try something like that:
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:
Exactly as you'd imagine:
swift 4
swift 3
https://developer.apple.com/reference/foundation/nsvalue/1624531-init