How to convert CGPoint in NSValue in swift?

前端 未结 5 1678
北海茫月
北海茫月 2020-12-11 00:34

As my question title says how can I convert CGPoint into NSValues so I can store then Into array In swift.

In objective-C

5条回答
  •  旧巷少年郎
    2020-12-11 01:15

    Exactly as you'd imagine:

    let point = CGPoint(x: 9.0, y: 9.0)
    let pointObj = NSValue(CGPoint: point)
    let newPoint = pointObj.CGPointValue()
    

提交回复
热议问题