首页
注册
登录
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请
登录
›
Swift Blog
›
Swift.org
›
Swift Programming on Medium
›
Vapor
›
Perfect Web Framework
›
Kitura Web Framework
V2EX
›
Swift
Swift 中如何使用 UnsafePointer(方法传参)
WildCat
·
2014-10-06 17:35:45 +08:00
· 6343 次点击
这是一个创建于 3811 天前的主题,其中的信息可能已经有所发展或是发生改变。
在用Swift重写一个开源边栏菜单,但是遇到个问题,就是
vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, (uint32_t)radius, (uint32_t)radius, 0, kvImageEdgeExtend);
这样的语句,用Swift不知道怎么写。虽然搜到了一个类似问题
http://stackoverflow.com/questions/24110769/how-to-correctly-initialize-an-unsafepointer-in-swift
,但是 withUnsafePointer(&arg: T, body: (UnsafePointer<T>) -> Result) 这里有个闭包不知道如何写。
在
https://github.com/rnystrom/RNFrostedSidebar/blob/master/RNFrostedSidebar.m
第99行。
感谢。
.js
radius
开源
Swift
4 条回复
•
2014-10-07 09:00:11 +08:00
1
timonwong
2014-10-06 18:55:52 +08:00
我没有用过swift,只是看看,这种调用可以直接掉啊:
https://developer.apple.com/library/ios/documentation/swift/conceptual/buildingcocoaapps/InteractingWithCAPIs.html#//apple_ref/doc/uid/TP40014216-CH8-XID_14
2
WildCat
OP
2014-10-06 21:59:48 +08:00
@
timonwong
不行,IDE就报错的。
'vImage_Buffer' is not convertible to 'UnsafePointer<vImage_Buffer>'
3
timonwong
2014-10-07 08:39:11 +08:00
1
@
WildCat
func takesAMutablePointer(x: UnsafeMutablePointer<Float>) { /*...*/ }
var x: Float = 0.0
takesAMutablePointer(&x)
4
WildCat
OP
2014-10-07 09:00:11 +08:00
@
timonwong
不行的,我用的这个方法就是无法调用
关于
·
帮助文档
·
博客
·
API
·
FAQ
·
实用小工具
·
5595 人在线
最高记录 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 28ms ·
UTC 06:48
·
PVG 14:48
·
LAX 23:48
·
JFK 02:48
Developed with
CodeLauncher
♥ Do have faith in what you're doing.