cs193p – Assignment #2 Task #2

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

Don’t violate any of the Required Tasks from Assignment 1 in the playing card game tab (in other words, don’t break any non-extra-credit features from last week). The only exception is that your playing card game is required to be a 2-card-match-only game this week, so you can remove the switch or segmented control you added for Required Task #5 in Assignment 1. Your Set game is a 3-card matching game.

Start by moving “everything” which is not matching-card specific to common game view controller. Note that all property declarations need to be in the .h file as well as those methods you need to access from your subclasses and from storyboard (e.g. action methods).
Continue reading “cs193p – Assignment #2 Task #2”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #2 Task #1

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

Add a tab bar controller to your application. One tab will be the game you built last week in Assignment 1. The other tab will be a new game, Set. Set is still a card game, so a good solution to this assignment will use object-oriented programming techniques to share a lot of code.

Start by creating a new view controller class GameViewController, and another one SetGameViewController which inherits from the first one. Make the first class also the parent class for the CardGameViewController:

#import "GameViewController.h"
@interface CardGameViewController : GameViewController

GameViewController will hold the “common parts” of the to card game view controllers …

The tab bar controller has already been added during lecture #5. Drag out an additional view controller and link it to the new SetGameViewController class.

The complete code is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Lecture #5 – View Controller Lifecycle and Multiple MVCs

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

Lecture #5 covers the view-controller life cycle and multiple MVCs and finishes with another demo of the Matchismo card game.

viewDidLoad is a good place to hold setup code – but has not geometry set yet.
viewWillAppear is for geometry-related initialization, lazy execution and late updating.

“A view gets loaded only once, but can appear and disappear a lot.”

viewWillDisAppear is suitable to “remember” and “clean up”.
view{Will,Did}LayoutSubviews is suitable to react to geometry changes.

Autorotation is controlled by shouldAutorotate
Continue reading “cs193p – Lecture #5 – View Controller Lifecycle and Multiple MVCs”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Lecture #4 – Foundation, Attributed Strings

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

Lecture #4 provides more insight into Objective-C and introduction to the Foundation framework.

… more about nil, instantiation, dynamic binding, compile time vs run time, object typing, introspection …

A short demo shows how match: of PlayingCard can be improved by introspection.

The code of Matchismo for this lecture is available at Stanford and on github.

… more about description, copy & mutableCopy, NSArray, enumeration, NSNumber, NSValue, NSData, NSDate, NSSet, NSOrderedSet, NSDictionary, porperty lists, NSUserDefaults, NSRange, colors and fonts, UIColor, UIFont, and NSAttributedString.

The lecture finishes with another demo demonstrating attributed strings.

The code of the Attribute demo for this lecture is available on github.

Slides are available on iTunes …..

The lecture is available at iTunes and is named “4. Foundation, Attributed Strings (January 17, 2013)”.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #1 Extra Task

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

Add a UISlider to your UI which travels through the history of the currently-being- played game’s flips and display it to the user (moving the slider will modify the contents of the text label you created for Required Task #3 to show its state over the course of the game). When you are displaying past flips, you probably want the text label to be grayed out (with alpha) or something so it’s clear that it’s “the past.” Also, you probably don’t want that text label from Required Task #3 to ever be blank (except at the very start of the game, of course). And every time a new flip happens, you probably want to “jump to the present” in the slider. Implementing this extra credit item will require you to familiarize yourself with UISlider’s API and to add a data structure to your Controller to keep track of the history. It can be implemented in fewer than a dozen lines of code.

Add a new property to hold the history information and initialize it using its getter:
Continue reading “cs193p – Assignment #1 Extra Task”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #1 Task #7

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

Make the back of the card be an image (UIImage) rather than an Apple logo.

Add an image to your project (e.g. cardback.png), create an UIImage from it, use it when the back of the card is shown, and remove it when it is face up:

- (void)updateUI
{
    UIImage *cardBackImage = [UIImage imageNamed:@"cardback.png"];
    
    for (UIButton *cardButton in self.cardButtons) {
        ...
        if (!card.isFaceUp) {
            [cardButton setImage:cardBackImage 
                        forState:UIControlStateNormal];            
        } else {
            [cardButton setImage:nil forState:UIControlStateNormal];
        }
    }
    ...
}

The complete code is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #1 Task #6

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

Disable the game play mode control (i.e. the UISwitch or UISegmentedControl from Required Task #5) when flipping starts and re-enable it when a re-deal happens (i.e. the Deal button is pressed).

Disable the control element in flipCard:

- (IBAction)flipCard:(UIButton *)sender
{
    self.cardModeSelector.enabled = NO;
    ...
}

… and enable it in dealButtonPressed:

- (IBAction)dealButtonPressed:(UIButton *)sender {
    ...
    self.cardModeSelector.enabled = YES;
    ...
}

The complete code is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail