Users Timeline Display


#1

I’m trying to follow the tutorial for displaying a single users’ timeline in an app, using Fabric. The problem is, they leave out all of the steps for creating a viewController to do this. They simply state:

Finally, create a TWTRTimelineViewController as the view controller to present the timeline and provide it with the preconfigured instance from above. TWTRTimelineViewController will handle loading of Tweets and recycling Tweet views as appropriate.

I don’t know how to do any of that, and make it show the view…any help would be greatly appreciated.


#2

Hi TBrass84
Add a table view to your blank view controller on the storyboard. Command click and drag from the table view to the view controller box again in the storyboard (The yellow circle icon with the white square in it) When you release set the view controller as the table’s datasource.
Now go into the ViewController.Swift file and make sure it inherits from TWTRTimelineViewController instead of a UIViewController and you should be in business. Final code should look similar to below:

mport UIKit
import TwitterKit

class ViewController: TWTRTimelineViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    
    Twitter.sharedInstance().logInGuestWithCompletion { session, error in
        if let validSession = session {
            let client = Twitter.sharedInstance().APIClient
            self.dataSource = TWTRUserTimelineDataSource(screenName: "TwitterAccountName", APIClient: client)
        } else {
            print("error: \(error.localizedDescription)")
        }
    }

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

#3