Sharing Data Between View Controllers

Now that we can get the selected tweet, we need a way to communicate between the view controllers. Actually, our tweet detail view controller may want more information than we have in the ParsedTweet, or things that the home_timeline API doesn’t even provide, so we’ll need a way to pass the tweet’s unique identifier to the second view controller, and then let that view controller get whatever details it needs via a new Twitter API call.

So, add a tweetIdString to ParsedTweet.swift:

Navigation/PragmaticTweets-9-2/PragmaticTweets/ParsedTweet.swift
 
var​ tweetIdString : String?

In the Twitter API response, the tweet’s unique ID string is identified with the key id_str, so that’s what we need to get from the ...

Get iOS 8 SDK Development, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.