cs193p – Assignment #2 Task #2

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

Add a button which will re-deal all of the cards (i.e. start a new game). It should reset the score (and anything else in the UI that makes sense). In a real game, we’d probably want to ask the user if he or she is “sure” before aborting the game in process to re-deal, but for this assignment, you can assume the user always knows what he or she is doing when they hit this button.

Start by dragging out a new button onto your storyboard. Note that the blue font on a green background is not really readable. You might want to change the color of the button text or its background:

cs193p – assignment #2 task #2 - deal button
cs193p – assignment #2 task #2 – deal button

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.

Follow the detailed instructions in the lecture slides (separate document) to reproduce the latest version of Matchismo we built in lecture (i.e. the one with multiple cards) and run it in the iPhone Simulator. Do not proceed to the next steps unless your card matching game functions as expected and builds without warnings or errors.

Thethe slides provided with lecture #3 contain a detailed walk through for the rest of the first assignment and all the steps described above. Follow those steps and (if you have not finished them already during the lecture) you have completed the first task of the second assignment.

The complete code is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Lecture #4 – Foundation and Attributed Strings

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

Lecture #4 is mostly theory with a tiny demonstration in between.

It starts with an introduction to foundation objects and how to create them using initializers or special class methods. The demo shows how to use introspection to safely use dynamic typing.

Further objects of the foundation framework explained during the lecture are mutable and immutable arrays (as well as enumeration), numbers, values, data objects, dates, sets (ordered, unordered), and dictionaries.

New for iOS 7 is preferredFontForTextStyle for fonts and font descriptors.

The lecture ends with attributed strings …

The code for this lecture is available at github.

The lecture as well as its slides are available via iTunes called “4. Foundation and Attributed Strings”.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Lecture #3 – Objective-C

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

Lecture #3 is a demonstration of how to solve the previous assignment and adds new features to the Matchismo app by adding additional cards and a card-matching algorithm.

The code for this lecture is available at github.

The lecture as well as its slides (which include a complete walk through of the demo from the lecture) are available via iTunes called “3. Objective-C”.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #1 Task #5

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

Matchismo so far only displays the A♣ over and over. Fix Matchismo so that each time the card is flipped face up, it displays a different random card drawn from the
Deck property you’ve created above. In other words, Matchismo should flip through an entire deck of playing cards in random order, showing each card one at a time.

Because we will draw random cards, we should not start with the As of clubs but with the back of the card. We could do that in various ways, e.g. adjusting the story board (remove the text of the button and set the background to the correct image). If you want to adjust the button from inside the view controller, we need to add an outlet. Now we could use this outlet to access and manipulate the button as soon as the view has loaded. e.g. we could set the background and the title of the button. … because I am lazy I just call the existing method to flip the card using the outlet property as argument:

@property (weak, nonatomic) IBOutlet UIButton *cardButton;
...
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self touchCardButton:self.cardButton];
    self.flipCount = 0;
}

Continue reading “cs193p – Assignment #1 Task #5”

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail

cs193p – Assignment #1 Task #4

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

Use lazy instantiation to allocate and initialize this property (in the property’s getter)
so that it starts off with a full deck of PlayingCards.

Use the getter to check if there is a valid deck. If not, initialize one …

#import "PlayingCardDeck.h"
...
- (Deck *)deck
{
    if (!_deck) {
        _deck = [[PlayingCardDeck alloc] init];
    }
    return _deck;
}

The complete code is available on github.

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail