Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
470 views
in Technique[技术] by (71.8m points)

ios - How to convert CGPoint in NSValue in swift?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try something like that:

let point = CGPointMake(9, 9)
var pointObj = NSValue(CGPoint: point)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...