[iOS] TWTRTimelineViewController tweets not displaying


#1

I followed the developer documentation https://dev.twitter.com/twitter-kit/ios/show-timelines to display a timeline of tweets in my application. However after I log-in I just see an empty table view.

I had to add the following line to get the code to compile:

    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }

I’d be extremely appreciative of any pointers on what’s going wrong. Or if someone could point me to some simple sample code which uses Fabric to display a timeline of tweets that would be great.

I took a look at Cannonball iOS but they are using TWTRTweetViewDelegate technique instead of the TWTRTimelineViewController in the documentation.

My full class looks like this:

import UIKit
import TwitterKit

class SearchTimelineViewController: TWTRTimelineViewController {
    convenience init() {
        let client = Twitter.sharedInstance().APIClient
        let dataSource = TWTRSearchTimelineDataSource(searchQuery: "#twitterflock", APIClient: client)
        self.init(dataSource: dataSource)
    }
    
    override required init(dataSource: TWTRTimelineDataSource) {
        super.init(dataSource: dataSource)
    }
    
    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
}

Happy to post my entire project online if it’s useful.

Thanks,
Pete


TWTRTimelineViewController crashes: "initWithCoder: unrecognized selector sent to instance"
Mopub usage with TwitterKit for iOS
[iOS] Twitter Timeline
#2

Hi Pete!

I whipped up a quick sample for you:

Main.storyboard:

LoginViewController:

import UIKit
import TwitterKit

class LoginViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let logInButton = TWTRLogInButton(logInCompletion: {
            (session: TWTRSession!, error: NSError!) in

            let vc = ViewController()
            
            self.presentViewController(vc, animated: true, completion: nil)
        
        })
        logInButton.center = self.view.center
        self.view.addSubview(logInButton)
    }
}

ViewController:

import UIKit
import TwitterKit

class ViewController: TWTRTimelineViewController {

    convenience init() {
        let client = Twitter.sharedInstance().APIClient
        let dataSource = TWTRUserTimelineDataSource(screenName: "fabric", APIClient: client)
        
        self.init(dataSource: dataSource)
    }
    
    override required init(dataSource: TWTRTimelineDataSource) {
        super.init(dataSource: dataSource)
    }
    
    required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

Here’s the result:

Hope that helps!


#3

Hi Val,

That works great for me.

Thanks very much for your help,
Pete


closed #4