Can't get user screen name from session

ios
swift
api

#1

Hello,

I’m trying to get the screen name of a user already logged in but I just don’t seem to be able to extract it out of session. I found a similar problem with an answer in stackoverflow and even though it makes sense it didn’t work for me.

I’ll post the solution below but the loadUserWithID never enters the completion handler.

if let session = Twitter.sharedInstance().sessionStore.session() {
    let client = TWTRAPIClient()
    client.loadUserWithID(session.userID) { (user, error) -> Void in
        if let user = user {
            print("@\(user.screenName)")
        }
    }
}

Any idea how I could get the screen name? Or is the away to display the timeline just have the userID??


#2

Can you share any output you’re seeing in the console when this isn’t working for you?