我在這段代碼得到這個錯誤「無法轉換爲PFUserResultBlock」我這裏有在Xcode中,斯威夫特:一小段代碼斯威夫特錯誤:無法轉換爲PFUserResultBlock
有誰可能知道爲什麼我得到這個錯誤?
我在這段代碼得到這個錯誤「無法轉換爲PFUserResultBlock」我這裏有在Xcode中,斯威夫特:一小段代碼斯威夫特錯誤:無法轉換爲PFUserResultBlock
有誰可能知道爲什麼我得到這個錯誤?
要匹配的PFUserResultBlock
typedef void (^PFUserResultBlock)(PFUser *PF_NULLABLE_S user, NSError *PF_NULLABLE_S error);
請改變你的代碼typedef
到
PFTwitterUtils.logInWithBlock { (user: PFUser?, error: NSError?) -> Void in
使得PF_NULLABLE_S
註釋尊重。
謝謝大家,特別是丹尼爾。丹尼爾的解決方案爲我工作。 另外,在我第一次問這個問題的前一張照片中,我手動輸入了所有內容。當使用Daniel提出的Xcode的鍵入自動完成功能時,它顯示並顯示代碼。 我有我的情況下別人什麼工作的圖片會看看這個帖子在未來: twitter login in xcode 7
繼海莉建議:
import UIKit
import Parse
import ParseTwitterUtils
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
// override func didReceiveMemoryWarning() {
// super.didReceiveMemoryWarning()
//
// Dispose of any resources that can be recreated.
// }
@IBAction func loginWithTwitterTapped(sender: AnyObject) {
PFTwitterUtils.initializeWithConsumerKey("XWvwtGCsXKkz3yAjKJpCv6mOA", consumerSecret:"gmSVhubFvVl1dILSxfRiCCkTb9PfPAcoCyN3i2SS6JgD5up3cz")
PFTwitterUtils.logInWithBlock { (user:PFUser?, error:NSError?) -> Void in
if user == nil {
print(error)
} else {
print("WE DID IT")
}
}
}
}
我很高興你能夠得到它的工作。 – Daniel
請提供PFUserResultBlock規範,它不是一個標準的框架,所以並不是所有人都會熟悉。 –
這有幫助嗎? http://stackoverflow.com/questions/24900090/objective-c-to-swift-methods-call –
如果將代碼/錯誤包含在文本中而不是圖像中,則更有可能獲得問題的答案。 –