cs193p – Project #4 Assignment #4 Extra Task #2

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

When you click on a user in the Users section, search not only for Tweets that mention that user, but also for Tweets which were posted by that user.

If the query is a user name (starts with an @ sign) change the search query to look also for the poster:

    var nextRequestToAttempt: TwitterRequest? {
        ...
            if searchText != nil {
                var query = searchText!
                if query.hasPrefix("@") {
                    query = "\(query) OR from:\(query)"
                }
                return TwitterRequest(search: query, count: 100)
            } ...
    }

The complete code for extra task #2 is available on GitHub.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #4 Assignment #4 Extra Task #1

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

In the Users section of your new UITableViewController, list not only users mentioned in the Tweet, but also the user who posted the Tweet in the first place.

Add the users screen name including a leading @ sign:

    var tweet: Tweet? {
        didSet {
            ...
            if let users = tweet?.userMentions {
                var userItems = [MentionItem.Keyword("@" + tweet!.user.screenName)]
                if users.count > 0 {
                    userItems += users.map { MentionItem.Keyword($0.keyword) }
                }
                mentions.append(Mentions(title: "Users", data: userItems))
            }
        }
    }

The complete code for extra task #1 is available on GitHub.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #4 Assignment #4 Task #10

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

Your application must work properly in portrait or landscape on any iPhone (this is an iPhone-only application).


… hopefully, it works already. Are all auto-layout constraints of the cell views in place?

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #4 Assignment #4 Task #9

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

You must not block the main thread of your application with a network request at any time.

Hopefully, we took care of this already in our “new” code. But there is a legacy from the code of the lecture which needs a minor tweak. Move the download of the profile images to an asynchronous queue, when the images has been download, check if the image is still valid (the tweet for this image might not be on screen any more) and set the image:
Continue reading “cs193p – Project #4 Assignment #4 Task #9”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #4 Assignment #4 Task #8

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

Keep track of the most recent 100 Twitter searches the user has performed in your application. Add a UITabBarController to your application with a tab for searching (i.e. your main UI) and a second tab showing these most recent search terms in a table view (uniqued with most recent first). When a user clicks on a search term in the second tab, segue (stay in that same tab) to show the most recent Tweets matching that search term. Store these most recent searches permanently in NSUserDefaults so that your application doesn’t forget them if it is restarted.

Embed the current initial view controller (which should be your navigation view controller) in a tab view controller. Add a new table view controller and embed it in a navigation view controller. Add this new navigation view controller to the tab view controller, and choose nice icons for the two new tabs of the tab view controller. Create a new class for the new table view controller and segue from its cell to the twitter table view controller. Don’t forget to provide sensible names for the cell and the segue identifiers:

cs193p - Project #4 Assignment #4 Task #8 - tab view controller
cs193p – Project #4 Assignment #4 Task #8 – tab view controller

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

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Project #4 Assignment #4 Task #7

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

If the user clicks on an image in your newly created view controller, segue to a new MVC which lets the user scroll around and zoom in on the image. When the image first appears in the MVC, it should display zoomed (in its normal aspect ratio) to show as much of the image as possible but with no “whitespace” around it.

Copy the image-view controller from the storyboard of the Cassini project to the smashtag storyboard and create a segue from the image-table-view cell to the new view controller:

cs193p - Project #4 Assignment #4 Task #7 - image view controller
cs193p – Project #4 Assignment #4 Task #7 – image view controller

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

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

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