cs193p – Project #4 Assignment #4 Task #6

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

If the user clicks on a mentioned url in your newly created view controller, you should open up that url in Safari (see Hints below for how to do that).

Before a segue fires, check if the keyword is actually a link. If so, block it from firing and open the link instead:

    override func shouldPerformSegueWithIdentifier(identifier: String?, sender: AnyObject?) -> Bool {
        if identifier == Storyboard.KeywordSegueIdentifier {
            if let cell = sender as? UITableViewCell {
                if let url = cell.textLabel?.text {
                    if url.hasPrefix("http") {
                        UIApplication.sharedApplication().openURL(NSURL(string: url)!)                        
                        return false
                    }
                }
            }
        }
        return true
    }

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

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #4 Assignment #4 Task #5

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

Continue reading “cs193p – Project #4 Assignment #4 Task #5”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #4 Assignment #4 Task #4

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

If a section has no items in it, there should be no header visible for that section.

… oops, didn’t notice that. We need to check if there are items to show:

    var tweet: Tweet? {
        ...
                if media.count > 0 { ... }
            ...
                if urls.count > 0 { ... }
            ...
                if hashtags.count > 0 { ... }
            ...
                if users.count > 0 { ... }
            ...
    }

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

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #4 Assignment #4 Task #3

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

Each section in the mentions table view should have an appropriate header.

We store already the title in our data structure, now just use it:

    override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
        return mentions[section].title
    }

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

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #4 Assignment #4 Task #2

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

When a user clicks on a Tweet, segue to a new UITableViewController which has four sections showing the “mentions” in the Tweet: Images, URLs, Hashtags and Users. The first section displays (one per row) any images attached to the Tweet (found in the media variable in the Tweet class). The last three show the items described in Required Task 1 (again, one per row).

Add a new table view controller to story board and a new table-view-controller class which you link to the new controller. Add a segue from the tweet cell too the new controller (don’t forget to add a segue identifier).
Continue reading “cs193p – Project #4 Assignment #4 Task #2”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #4 Assignment #4 Task #1

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

Enhance Smashtag from lecture to highlight (in a different color for each) hashtags, urls and user screen names mentioned in the text of a Tweet (these are known as “mentions”). Note that mentions are already located for you in each Tweet by Twitter and show up as [IndexedKeyword]s in the Tweet class in the supplied Twitter code.

The tweet class provides nearly everything needed – arrays of indexed keywords. What’s left is to choose a color for the keyword type – as public properties of the cell view:

    var hashtagColor = UIColor.blueColor()
    var urlColor = UIColor.redColor()
    var userMentionsColor = UIColor.greenColor()

Continue reading “cs193p – Project #4 Assignment #4 Task #1”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Lecture #12 Dynamic Animation

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

The twelfth lecture addresses a different approach to animation, creating sets of behaviors defining how items should interact with each other and the environment.

First we create an animator inside a reference view:

var animator = UIDynamicAnimator(referenceView: UIView)

Continue reading “cs193p – Lecture #12 Dynamic Animation”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail