let pointer:UnsafeMutablePointer<CGPoint> = CGPoint(x: 0,y: 1) as! UnsafeMutablePointer<CGPoint>self.scrollVIEwWillEndDragging(self.collectionVIEw,withVeLocity: CGPoint(x: 0,y: 1),targetContentOffset: pointer)func scrollVIEwWillEndDragging(scrollVIEw: UIScrollVIEw,withVeLocity veLocity: CGPoint,targetContentOffset: UnsafeMutablePointer<CGPoint>) { //Some code here}解决方法
import Foundationvar point = CGPoint(x: 10.0,y: 20.0)let p = withUnsafeMutablePointer(&point) { (p) -> UnsafeMutablePointer<CGPoint> in return p}print(p.memory.x,p.memory.y) // 10.0 20.0point.x = 100.0print(p.memory.x,p.memory.y) // 100.0 20.0
借助斯威夫特的句法糖
import Foundationvar point = CGPoint(x: 10.0,y: 20.0)let p = withUnsafeMutablePointer(&point) { }print(p.dynamicType) // UnsafeMutablePointer<CGPoint>总结
以上是内存溢出为你收集整理的ios – 如何在swift中创建UnsafeMutablePointer对象全部内容,希望文章能够帮你解决ios – 如何在swift中创建UnsafeMutablePointer对象所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)