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”