cs193p – Project #4 Assignment #4 Task #5

Peter Newell [Public domain], via Wikimedia Commons

Please note, this blog entry is from a previous course. You might want to check out the current one.

If a user touches an entry for a hashtag or a user in the “mentions table view” that you created in Required Task 2 above, you should segue to show the results of searching Twitter for that hashtag or user. It should be searching for hashtags or users, not just searching for a string that is the name of the hashtag or user (e.g. search for “#stanford”, not “stanford”). The view controller to which you segue must work identically to your main Tweet-viewing view controller (TweetTableViewController).

Create a segue from the keyword cell to the initial table view controller (and name its identifier):

cs193p - Project #4 Assignment #4 Task #5 - Storyboard
cs193p – Project #4 Assignment #4 Task #5 – Storyboard


Preparing the segue set the search text to the text of the current text label (and for now we ignore that this will also fire searches for mentioned links):

    private struct Storyboard {
        ...
        static let KeywordSegueIdentifier = "From Keyword"
    }
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        if let identifier = segue.identifier {
            if identifier == Storyboard.KeywordSegueIdentifier {
                if let ttvc = segue.destinationViewController as? TweetTableViewController {
                    if let cell = sender as? UITableViewCell {
                        ttvc.searchText = cell.textLabel?.text
                    }
                }
            }
        }
    }

The complete code for task #5 is available on GitHub.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

Leave a Reply

Your email address will not be published.