didReceiveRequestToken

didReceiveRequestToken

这是可以在Objective-C中正常运行的工作代码,

[dataFetcher fetchDataWithRequest:authorizeRequest
                         delegate:self
                didFinishSelector:@selector(didReceiveRequestToken:data:)
                  didFailSelector:@selector(didFailOAuth:error:)];


它在Objective-C中同时调用这两种方法。

但是当我在Swift中使用Selector时,它不起作用。

dataFetcher?.fetchDataWithRequest(requestTokenRequest,
                    delegate: self,
                    didFinishSelector:Selector("didReceiveRequestToken:data:"),
                    didFailSelector: Selector("didFailOAuth:error:"))


这是我正在调用的方法,

func didReceiveRequestToken(ticket:OAServiceTicket,data:NSData){

}


我已经使用过StackOverFlow上提供的解决方案,但是它们对我没有用。

提前致谢。

最佳答案

您的方法有一些变化:

func didReceiveRequestToken(ticket:OAServiceTicket,andData data:NSData){
}


选择器是:“ didReceiveRequestToken:andData:”

你的来电:

dataFetcher?.fetchDataWithRequest(requestTokenRequest,
                delegate: self,
                didFinishSelector:"didReceiveRequestToken:andData:",
                didFailSelector:"didFailOAuth:andError:") // Make the same with this.


确保您的代码具有此方法。

10-07 12:55