cs193p – Assignment #4 Task #3 & #7

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

The main (non-Recents) tab must present a list containing all of the tags (FLICKR_TAGS) on all of the photos queried except the tags “cs193pspot,” “portrait” & “landscape” (note that Flickr tags come back all lower case with no special characters). The subtitle for each cell in this list should display how many photos have the corresponding tag. Capitalize the tags so they look a bit nicer in the list.

All lists should each be displayed in a UITableView.

Create a new UITableViewController sub class. The model of the controller needs two properties. An array to store the photos received from Flickr and a dictionary where those photos are sorted by its tags:

@property (nonatomic, strong) NSArray *photos; // of NSDictionary
@property (nonatomic, strong) NSDictionary *photosByTag; // of NSArray of NSDictionary

Continue reading “cs193p – Assignment #4 Task #3 & #7”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #4 Task #2

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

Your user-interface should present a UITabBarController-based UI with two tabs, each of which contains its own navigation (i.e. UINavigationController-based) stack. One tab lets you browse (in the manner described below) all of the photos returned in the above query and another which maintains a list of the photos the user has most recently viewed in your application.

In storyboard (currently we stay with the iPhone and ignore the iPad) use the “embed-in” functionality to add a navigation view controller. Copy both view controllers. Use the “embed-in” functionality to add a tab view controller. Connect the tab view controller also to the second navigation view controller. Name and set icons accordingly:

cs193p - assignment #4 task #2
cs193p – assignment #4 task #2

The complete code is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #4 Task #1

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

You will be using the method stanfordPhotos in the provided FlickrFetcher helper code to get an NSArray of Flickr photos of various sites on the Stanford campus. Each entry in the NSArray is an NSDictionary object with numerous entries which describe the photo (more on this below). FlickrFetcher.h has #defines for the keys.

Create a new single-view project. Because the we know already that it should also run on iPads in the near future (extra task #2 or next assignment) make it universal. Add the Flickr-API to the project by dragging in the provided files (or get them from Shutterbug). Get the API key directly from Flickr and set it in FlickrAPIKey.h.

For now – we will not use it later on – add some test code to the automatically generated view controller to see if the interface to Flickr works.

#import "FlickrFetcher.h"
...
- (void)viewDidLoad
{
    [super viewDidLoad];
    NSLog(@"%@", [FlickrFetcher stanfordPhotos]);
}

The complete code is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Lecture #9 – Scroll View and Table View

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

Lecture #9 starts with an update concerning the view-controller lifecycle. Where pre-Autolayout you would have used viewWillAppear: for geometry based initialization, you should now use viewDidLayoutSubviews: because the first is called only when a view appears on screen and the later each time the bounds of of self.view change.

This is followed by a thorough introduction to scroll and table views. The second half of the lecture demonstrates both by populating a table view with information of photos from Flickr and to display them in a scroll view.

The code of the demo is available at Stanford and on github.

Slides are available on iTunes …..

The lecture is available at iTunes and is named “9. Scroll View and Table View (February 5, 2013)”.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #3 Extra Task #6

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

Make this a two player game. There’s no need to go overboard here. Think of a simple UI and a straightforward implementation that make sense.

Create a new property to hold the separate scores of the players and another one to know the current player:

@property (strong, nonatomic) NSMutableArray *playerScores; // of NSNumber
@property (nonatomic) int currentPlayer;
...
- (NSMutableArray *)playerScores
{
    if (!_playerScores) {
        _playerScores = [NSMutableArray arrayWithObjects:@0, @0, nil];
    }
    return _playerScores;
}

Continue reading “cs193p – Assignment #3 Extra Task #6”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #3 Extra Task #5

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

Knowing how to find Sets in the remaining cards also would allow you to let the user cheat. Have a button that will show them a Set (if available). It’s up to you how you want to show it, but maybe some little indicator (a star or something) on each of the 3 cards?

Start by adding a new button in storyboard:

cs193p - assignment #3 extra task #5
cs193p – assignment #3 extra task #5

Continue reading “cs193p – Assignment #3 Extra Task #5”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #3 Extra Task #4

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

You could add better score-keeping to the Set part of this application if you can figure out an algorithm for calculating whether a Set exists in the current cards in play. Then you can penalize the user not only for mismatches, but for clicking the “deal 3 more cards” button if he or she missed a Set. You’d also know when the game was “over” (because the user would click on “deal 3 more cards” and there would be no more cards in the deck and no more Sets to choose).

Create a new public method in the card-matching-game model which returns the first set of matching cards. The first possible combination of cards is just the first cards. Generate an array of their indexes with a simple for loop. Then check if the combination is valid (e.g. contains no unplayable card). Separate the first card and from the others using helper functions to check if they match. If they do, return those cards otherwise get the next possible combination, and start again with the checks:
Continue reading “cs193p – Assignment #3 Extra Task #4”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail