Hi Kang
Thank you so much for your help. I have tracked down the user ID I require but for some reason I am still unable to populate the table view using the sample code provided in the Twitter Kit documentation (I just get an empty table view like the cell is not connected). I have tried to access Twitter as a guest only in my code and then simply embed the timeline of a single user. I am very sorry for pasting large amounts of code but am unable to explain my problem properly without doing so. Any advice would be greatly appreciated. Thanks again.
**Edited code below as per my last comment on this post
import UIKit
import TwitterKit
class TwitterViewController: UITableViewController, TWTRTweetViewDelegate {
let tweetTableReuseIdentifier = "TweetCell"
// Hold all the loaded Tweets
var tweets: [TWTRTweet] = [] {
didSet {
tableView.reloadData()
}
}
let tweetIDs = [
"184701590"] // our favorite bike Tweet
override func viewDidLoad() {
Twitter.sharedInstance().logInGuestWithCompletion { guestSession, error in
if (guestSession != nil) {
Twitter.sharedInstance().APIClient.loadTweetsWithIDs(self.tweetIDs) { tweets, error in
if let ts = tweets as? [TWTRTweet] {
self.tweets = ts
} else {
println("Failed to load tweets: \(error.localizedDescription)")
}
}
}
}
// Setup the table view
tableView.estimatedRowHeight = 150
tableView.rowHeight = UITableViewAutomaticDimension // Explicitly set on iOS 8 if using automatic row height calculation
tableView.allowsSelection = false
tableView.registerClass(TWTRTweetTableViewCell.self, forCellReuseIdentifier: tweetTableReuseIdentifier)
}
// MARK: UITableViewDelegate Methods
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.tweets.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let tweet = tweets[indexPath.row]
let cell = tableView.dequeueReusableCellWithIdentifier(tweetTableReuseIdentifier, forIndexPath: indexPath) as TWTRTweetTableViewCell
cell.tweetView.delegate = self
cell.configureWithTweet(tweet)
return cell
}
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
let tweet = tweets[indexPath.row]
return TWTRTweetTableViewCell.heightForTweet(tweet, width: CGRectGetWidth(self.view.bounds))
}
}