1
SwiftでperformSelectorの代わりになるものは何ですか?以下は私のコードです。 DFURLPrepareクラスメソッドでコメントしたステートメントを更新する必要があります。SwiftでperformSelectorの必要な代替手段
class Login {
func loginRequest(url:String, dictParams: Dictionary <String, String>)
{
let urlPrepare = DFURLPrepare()
urlPrepare.sendRequest(self, url: url, dictParams: dictParams, successMethod: "getDefaultItemsResponse", errorMethod: nil)
}
}
class DFURLPrepare {
func sendRequest (delegate:AnyObject, url : String, dictParams: Dictionary <String, String>,successMethod: String?, errorMethod:String?){
let networkObj = Network()
let requestResource = Resource(url:url,paramdict: dictParams)
networkObj.load(requestResource){ data, response, error in
if let httpResponse = response as? NSHTTPURLResponse {
let statusCode = httpResponse.statusCode
if statusCode == 200 && data != nil{
/// *************Here as in objeactive C **************//
/// [self.delegate performSelector:successMethod withObject:data]];
///// What would be code at place of above statement
}
}
}
}
}
:
しかし、閉鎖は、多くのスウィフトプログラマがより好ましい方法であろう使用デリゲートの型はそれであり、デリゲートのメソッドを実行するのは奇妙なセレクタではなく、j ustメソッド –