-2
我是xcode的新手。我想將下面的目標C代碼轉換爲快速等效。Swift等價客觀代碼
ActionStringCancelBlock cancel = ^(ActionSheetStringPicker *picker) {
NSLog(@"Block Picker Canceled");
};
在此先感謝。
我是xcode的新手。我想將下面的目標C代碼轉換爲快速等效。Swift等價客觀代碼
ActionStringCancelBlock cancel = ^(ActionSheetStringPicker *picker) {
NSLog(@"Block Picker Canceled");
};
在此先感謝。
這是迅速相當於:
let cancel: ActionStringCancelBlock = { (picker: ActionSheetStringPicker) in
NSLog("Block Picker Canceled")
}
推薦閱讀:Closures
你可能只需要做到:
let cancel: ActionStringCancelBlock = { (picker: ActionSheetStringPicker!) in
println("Block Picker Canceled")
return
}
,但你可能會逃脫:
let cancel: ActionStringCancelBlock = {
println("Block Picker Canceled")
}