将obj-c代码转换为swift

时间:2015-08-08 19:13:42

标签: ios objective-c swift

我需要帮助将这个obj-c代码翻译成swift。我不确定我该怎么写一个块...

    self.circularTimerView.frameBlock = ^(CircularTimerView *circularTimerView){
        circularTimerView.text = [NSString stringWithFormat:@"%f", [circularTimerView intervalLength]];
    };

非常感谢你:)

1 个答案:

答案 0 :(得分:1)

你需要一个闭包而不是一个块:

circularTimerView.frameBlock = { [unowned self] (circularTimerView:CircularTimerView) in
    circularTimerView.text = NSString(format:"%f",circularTimerView.intervalLength())
}