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:

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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.