Neil Billingham Neil Billingham - 2 months ago 10x
Swift Question

Alternative for Twitter.sharedInstance().session()?.userName after deprecation on iOS Swift

I've been using

to display a user's twitter address in a Label in iOS (in Swift). Now I notice we get the following deprecation warning:

-[Twitter session] will soon be deprecated. It is
recommended that users use -[TWTRSessionStore session] or
-[TWTRSessionStore sessionForUserID:] if they are managing multiple users

I switched to the recommend way, and expected to find a
property around, but could not find one.

How are people going about swapping out
going forwards?


If you're still looking for the solution, here's one:

if let session = Twitter.sharedInstance().sessionStore.session() {
    let client = TWTRAPIClient()
    client.loadUserWithID(session.userID) { (user, error) -> Void in
        if let user = user {