快速等效于typedef

时间:2020-01-08 11:04:06

标签: ios swift

在C语言中,我会写类似:

    typedef struct old new;
struct old
{
    int x = 0;
    int y = 0;
};

我无法迅速找到对应的内容。

请帮助我

2 个答案:

答案 0 :(得分:1)

很快就会像这样:

typealias new = old

struct old {
    let x = 0
    let y = 0
}

答案 1 :(得分:1)

“ typealias”是所使用的关键字,它的作用是与typedef类似的迅速。

typealias MLAnimationCompletionBlock = (_ finished: Bool) -> Void

var blockVariable : MLAnimationCompletionBlock = { [weak self] (finished: Bool) -> Void in

       println(" this is a block that has bool input param and with void return")

    }