0
我在迅速的新嘗試客觀C座語法轉換迅速的Xcode 6.3.2如何將目標c的完成塊轉換爲Swift?
完成塊的typedef:
typealias CompletionWithBoolBlock = (Bool, NSError, NSString) -> Void
[Model insertObjectWithTable:@"tblStudent" values:dict completion:^(BOOL success, NSError *responseError, NSString *object){
if(success){
NSLog(@"inserted");
}
else
{
NSLog(@"Not inserted, %@",responseError.description);
}
}];
衝浪淨後,我試着用
Model.insertObjectWithTable("tblStudent", values: dict, completion:({(success:Bool,responseError:NSError, object:NSString)->(Void) in
if success
{
println("inserted")
}
else
{
println("Not inserted \(responseError.description)")
}
})
}
和
Model.insertObjectWithTable("tblStudent", values: dict, completion:(success:Bool,responseError:NSError, object:NSString)->Void{
if success
{
println("inserted")
}
else
{
println("Not inserted \(responseError.description)")
}
})
但它顯示我錯誤
預計 '' 分隔符
在表達式列表預計表達