Inherits from UITableViewController
Declared in TWTRTimelineViewController.h

Overview

This class is a UITableViewController subclass that displays TWTRTweetTableViewCell cells. It handles cell-reuse, cell-configuration, and loading more Tweets from the given timeline once the last cell is displayed.

Usage

Initialize this class with any object that conforms to the TWTRTimelineDataSource protocol. We provide two such classes, TWTRUserTimelineDataSource and TWTRSearchTimelineDataSource. These provide TWTRTweet objects to this table view which then configures the instances of TWTRTweetTableViewCell.

// Create the data source
TWTRAPIClient *client = [[TWTRAPIClient alloc] init];
TWTRUserTimelineDataSource *dataSource = [[TWTRUserTimelineDataSource alloc] initWithScreenName:@"jack" APIClient:client];

// Create the timeline view controller
TWTRTimelineViewController *timeline = [[TWTRTimelineViewController alloc] initWithDataSource:dataSource];

Loading More

This class loads the first batch of TWTRTweet objects from the Twitter API when viewWillAppear: is received. It also handles loading more tweets automatically once the last cell has been shown.

Properties

adConfiguration

The configuration of MoPub ads to show in the timeline. You must link against the MoPub framework and provide this configuration in order for ads to be injected.

@property (nonatomic, nullable) TWTRMoPubAdConfiguration *adConfiguration

Discussion

Note: Changing this will force a reload of the timeline. You can only set this once. Must be set on the main thread.

Declared In

TWTRTimelineViewController.h

dataSource

The source of TWTRTweet objects for this TWTRTimelineViewController. May be set to update the Tweets being shown by this table view. Must be set on the main thread.

@property (nonatomic, copy) id<TWTRTimelineDataSource> dataSource

Declared In

TWTRTimelineViewController.h

showTweetActions

Whether action buttons (Like, Share) should be shown on the TWTRTweetTableViewCells inside the tableview.

@property (nonatomic) BOOL showTweetActions

Declared In

TWTRTimelineViewController.h

timelineDelegate

The object that acts as the delegate for the timeline.

@property (nonatomic, weak) id<TWTRTimelineDelegate> timelineDelegate

Declared In

TWTRTimelineViewController.h

tweetViewDelegate

If set, this value will be passed to all TWTRTweetView instances in the timeline.

@property (nonatomic, weak) id<TWTRTweetViewDelegate> tweetViewDelegate

Declared In

TWTRTimelineViewController.h

Instance Methods

countOfTweets

Returns the number of Tweets that are currently displayed by the controller.

- (NSUInteger)countOfTweets

Declared In

TWTRTimelineViewController.h

initWithDataSource:

Initializes a timeline view controller. Does not start loading tweets until viewWillAppear: is called.

- (instancetype)initWithDataSource:(nullable id<TWTRTimelineDataSource>)dataSource

Parameters

dataSource

A timeline data source object that conforms to the TWTRTimelineDataSource protocol.

Return Value

A fully initialized TWTRTimelineViewController or nil if the data source is missing.

Discussion

This method must be used to initialize this class. The init method is unavailable.

Declared In

TWTRTimelineViewController.h

initWithDataSource:adConfiguration:

Initializes a timeline view controller with an optional ad configuration. Does not start loading Tweets until viewWillAppear: is called.

- (instancetype)initWithDataSource:(nullable id<TWTRTimelineDataSource>)dataSource adConfiguration:(nullable TWTRMoPubAdConfiguration *)adConfiguration

Parameters

dataSource

A timeline data source object that conforms to the TWTRTimelineDataSource protocol.

adConfiguration

Configuration for the type of MoPub ads to display. Ads will only load after the initial timeline is loaded. No ads will be displayed if nil.

Return Value

A fully initialized TWTRTimelineViewController. Tweets will not be loaded if the data source is nil.

Declared In

TWTRTimelineViewController.h

initWithStyle:

- (instancetype)initWithStyle:(UITableViewStyle)style

refresh

Asynchronously refresh and replace all the data in the table view with the latest TWTRTweets.

- (void)refresh

Declared In

TWTRTimelineViewController.h

snapshotTweets

  • Returns a copy of the Tweets at the time of calling this method.
- (NSArray *)snapshotTweets

Discussion

  • This method returns the copy of the current Tweets. The Tweets may change
  • after this method is called.

Declared In

TWTRTimelineViewController.h

tweetAtIndex:

Returns the Tweet at the given index.

- (TWTRTweet *)tweetAtIndex:(NSInteger)index

Discussion

Warning: This method will throw an exception if the index is out of range of the count of Tweets.

Declared In

TWTRTimelineViewController.h