WildCat
V2EX  ›  Swift

Swift 中如何使用 UnsafePointer(方法传参)

  •  
  •   WildCat · Oct 6, 2014 · 6829 views
    This topic created in 4262 days ago, the information mentioned may be changed or developed.
    在用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
    4 replies    2014-10-07 09:00:11 +08:00
    WildCat
        2
    WildCat  
    OP
       Oct 6, 2014
    @timonwong 不行,IDE就报错的。

    'vImage_Buffer' is not convertible to 'UnsafePointer<vImage_Buffer>'
    timonwong
        3
    timonwong  
       Oct 7, 2014   ❤️ 1
    @WildCat
    func takesAMutablePointer(x: UnsafeMutablePointer<Float>) { /*...*/ }
    var x: Float = 0.0
    takesAMutablePointer(&x)
    WildCat
        4
    WildCat  
    OP
       Oct 7, 2014
    @timonwong 不行的,我用的这个方法就是无法调用
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4607 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 05:36 · PVG 13:36 · LAX 22:36 · JFK 01:36
    ♥ Do have faith in what you're doing.