我有一個包含這在目的限定的塊的方法 - C:如何Objective-C的塊轉換爲夫特閉合
+(void)getNewList:(NewListRequestModel *)model returnInfo:(void(^)(NewListResponseModel* resModel))retModel;
和我調用它喜歡:
[API getNewList:model returnInfo:^(NewListResponseModel *resModel) {
//code
}];
在目的- C 。
現在我想調用它的雨燕3.2:
API.getNewList(model, returnInfo: {(resModel: NewListResponseModel) ->() in
//my code
})
但我總是得到一個錯誤:
Cannot convert value of type '(NewListResponseModel) -> Void' to expected argument type '((NewListResponseModel?) -> Void)!'
能有人幫我調用它的正確方法?謝謝。
你的意思是它改寫成快捷功能?但如果我不想重寫它,只需調用objective-c方法即可。你能說出正確的方法嗎? – Neko
在橋接頭文件中導入目標-c類並調用該函數。 – Pushpendra
它的工作原理,謝謝! – Neko