如何在swift中转换NSValue中的CGPoint? [英] How to convert CGPoint in NSValue in swift?

查看:97
本文介绍了如何在swift中转换NSValue中的CGPoint?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如我的问题标题所说我如何将 CGPoint 转换为 NSValues 所以我可以存储到数组中 swift

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

在Objective-C中我们可以这样做:

In objective-C we can do it like this:

  // CGPoint converted to NSValue
     CGPoint point = CGPointMake(9, 9);
     NSValue *pointObj = [NSValue valueWithCGPoint:point];

但有人能告诉我,我怎么能在swift中做到这一点?

But can anybody tell me that how can I do this in swift?

先谢谢。

推荐答案

尝试类似的事情:

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

这篇关于如何在swift中转换NSValue中的CGPoint?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆