且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Swift中使用TWTRShareEmailViewController(Fabric Twitter SDK)询问用户Twitter邮件

更新时间:2023-12-04 23:30:04

这应该大致将上述Objective-C转换为Swift:

This should roughly translate the above Objective-C to Swift:

if (Twitter.sharedInstance().session() != nil) {
        if let shareEmailViewController = TWTRShareEmailViewController(completion: {
            (email: String!, error: NSError!) in
            if (email != nil) {
                print("\(email)")
            } else {
                print("\(error)")
            }
        }) {
            self.presentViewController(shareEmailViewController, animated: true, completion: nil)
        }
    } else {
        print("User not logged in")
    }