我是xcode的新手。我想将下面的客观c代码转换为swift等价。
ActionStringCancelBlock cancel = ^(ActionSheetStringPicker *picker) {
NSLog(@"Block Picker Canceled");
};
提前致谢。
答案 0 :(得分:2)
这是快速的等价物:
let cancel: ActionStringCancelBlock = { (picker: ActionSheetStringPicker) in
NSLog("Block Picker Canceled")
}
建议阅读:Closures
答案 1 :(得分:2)
您可以这样做:
let cancel: ActionStringCancelBlock = { (picker: ActionSheetStringPicker!) in
println("Block Picker Canceled")
return
}
但你可能会逃避:
let cancel: ActionStringCancelBlock = {
println("Block Picker Canceled")
}