-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewController.m
More file actions
56 lines (47 loc) · 1.63 KB
/
ViewController.m
File metadata and controls
56 lines (47 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// ViewController.m
// SuperCard
//
// Created by Priyanjana Bengani on 17/12/2013.
// Copyright (c) 2013 anothercookiecrumbles. All rights reserved.
//
#import "ViewController.h"
#import "PlayingCardView.h"
#import "MatchismoPlayingCardDeck.h"
#import "MatchismoPlayingCard.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet PlayingCardView *playingCardView;
@property (strong, nonatomic) MatchismoDeck* deck;
@end
@implementation ViewController
- (MatchismoDeck*) deck{
if (!_deck) _deck = [[MatchismoPlayingCardDeck alloc] init];
return _deck;
}
- (void) drawRandomPlayingCard {
MatchismoCard* card = [self.deck drawRandomCard];
if ([card isKindOfClass:[MatchismoPlayingCard class]]) {
MatchismoPlayingCard* playingCard = (MatchismoPlayingCard*) card;
self.playingCardView.suit = playingCard.suit;
self.playingCardView.rank = playingCard.rank;
}
}
- (IBAction)swipe:(UISwipeGestureRecognizer *)sender {
if (!self.playingCardView.faceUp) [self drawRandomPlayingCard];
self.playingCardView.faceUp = !self.playingCardView.faceUp;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.automaticallyAdjustsScrollViewInsets = NO;
self.playingCardView.suit = @"♣︎";
self.playingCardView.rank = 13;
[self.playingCardView addGestureRecognizer:[[UIPinchGestureRecognizer alloc] initWithTarget:self.playingCardView
action:@selector(pinch:)]];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end