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

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

Make the “most recent searches” table be editable (i.e. let the user swipe left to delete the ones they don’t like).

We need a new method for our model/data source to be able to delete an entry from the user defaults:

    func removeAtIndex(index: Int) {
        var currentSearches = values
        currentSearches.removeAtIndex(index)
        values = currentSearches
    }

… and use it before removing the line from the table:

    override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
        if editingStyle == .Delete {
            RecentSearches().removeAtIndex(indexPath.row)
            tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
        }
    }

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

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

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

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

Instead of opening urls in Safari, display them in your application by segueing to a controller with a UIWebView. You’ll have to provide at least a little bit of “browser control” UI to go along with it (e.g. a “back button”).

Add a new view controller to the storyboard. Add a egue from the mentions table view controller to the new controller (be careful, not from a cell, but from the controller itself!). Add a web view, an activity indicator and a back button (don’t forget constraints for autolayout):

cs193p - Project #4 Assignment #4 Extra Task #4 - web view controller
cs193p – Project #4 Assignment #4 Extra Task #4 – web view controller

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

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

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

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

If you segue using Show (rather than Unwind), add some UI which will Unwind all the way back to the rootViewController of the UINavigationController. Even if you use Unwind (rather than Show), then if do the Collection View extra credit below using a Show segue, you might want the “unwind to root” behavior in scenes you segue to via the Collection View.

In both “root” view controllers (the tweet table view controller and the recent-searches table view controller) of the tab view controller add an unwind function as destination for the unwinding:

    @IBAction func unwindToRoot(sender: UIStoryboardSegue) { }

Continue reading “cs193p – Project #4 Assignment #4 Extra Task #3”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

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