From 1e7552bd463bd679495afda7f8cc5b3baa2a5ff1 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 21 Feb 2016 16:53:44 -0500 Subject: [PATCH 1/7] initial commit --- HeadsUpper/.gitignore | 1 + .../HeadsUpper.xcodeproj/project.pbxproj | 13 ++++ .../HeadsUpper/Base.lproj/Main.storyboard | 70 ++++++++++++++++--- HeadsUpper/HeadsUpper/GameData.h | 19 +++++ HeadsUpper/HeadsUpper/GameData.m | 29 ++++++++ .../HeadsUpper/TitlesTableViewController.h | 14 ++++ .../HeadsUpper/TitlesTableViewController.m | 64 +++++++++++++++++ HeadsUpper/HeadsUpper/ViewController.m | 6 ++ 8 files changed, 207 insertions(+), 9 deletions(-) create mode 100644 HeadsUpper/.gitignore create mode 100644 HeadsUpper/HeadsUpper/GameData.h create mode 100644 HeadsUpper/HeadsUpper/GameData.m create mode 100644 HeadsUpper/HeadsUpper/TitlesTableViewController.h create mode 100644 HeadsUpper/HeadsUpper/TitlesTableViewController.m diff --git a/HeadsUpper/.gitignore b/HeadsUpper/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/HeadsUpper/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj b/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj index fb900f8..652338d 100644 --- a/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj +++ b/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 5A3055D51C7A430E00100C42 /* TitlesTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A3055D41C7A430E00100C42 /* TitlesTableViewController.m */; }; + 5A4C555A1C7A62A70098B1B6 /* GameData.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A4C55591C7A62A70098B1B6 /* GameData.m */; }; 8D89695C1C755D0200D32E8A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D89695B1C755D0200D32E8A /* main.m */; }; 8D89695F1C755D0200D32E8A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D89695E1C755D0200D32E8A /* AppDelegate.m */; }; 8D8969621C755D0200D32E8A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D8969611C755D0200D32E8A /* ViewController.m */; }; @@ -16,6 +18,10 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 5A3055D31C7A430D00100C42 /* TitlesTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TitlesTableViewController.h; sourceTree = ""; }; + 5A3055D41C7A430E00100C42 /* TitlesTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TitlesTableViewController.m; sourceTree = ""; }; + 5A4C55581C7A62A70098B1B6 /* GameData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameData.h; sourceTree = ""; }; + 5A4C55591C7A62A70098B1B6 /* GameData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameData.m; sourceTree = ""; }; 8D8969571C755D0200D32E8A /* HeadsUpper.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HeadsUpper.app; sourceTree = BUILT_PRODUCTS_DIR; }; 8D89695B1C755D0200D32E8A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 8D89695D1C755D0200D32E8A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; @@ -62,6 +68,10 @@ 8D89695E1C755D0200D32E8A /* AppDelegate.m */, 8D8969601C755D0200D32E8A /* ViewController.h */, 8D8969611C755D0200D32E8A /* ViewController.m */, + 5A3055D31C7A430D00100C42 /* TitlesTableViewController.h */, + 5A3055D41C7A430E00100C42 /* TitlesTableViewController.m */, + 5A4C55581C7A62A70098B1B6 /* GameData.h */, + 5A4C55591C7A62A70098B1B6 /* GameData.m */, 8D8969631C755D0200D32E8A /* Main.storyboard */, 8D8969661C755D0200D32E8A /* Assets.xcassets */, 8D8969681C755D0200D32E8A /* LaunchScreen.storyboard */, @@ -150,7 +160,9 @@ buildActionMask = 2147483647; files = ( 8D8969621C755D0200D32E8A /* ViewController.m in Sources */, + 5A4C555A1C7A62A70098B1B6 /* GameData.m in Sources */, 8D89695F1C755D0200D32E8A /* AppDelegate.m in Sources */, + 5A3055D51C7A430E00100C42 /* TitlesTableViewController.m in Sources */, 8D89695C1C755D0200D32E8A /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -300,6 +312,7 @@ 8D8969701C755D0200D32E8A /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard b/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard index f56d2f3..73a6bed 100644 --- a/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard +++ b/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard @@ -1,25 +1,77 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - + + - + - + - + + + + + + + + + + + + + + + + + + + + diff --git a/HeadsUpper/HeadsUpper/GameData.h b/HeadsUpper/HeadsUpper/GameData.h new file mode 100644 index 0000000..2fcb99e --- /dev/null +++ b/HeadsUpper/HeadsUpper/GameData.h @@ -0,0 +1,19 @@ +// +// GameData.h +// HeadsUpper +// +// Created by Brian Blanco on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import + +@interface GameData : NSObject + +@property (strong, nonatomic) NSDictionary *superstars; +@property (strong, nonatomic) NSDictionary *the90s; +@property (strong, nonatomic) NSDictionary *mrDJ; +@property (strong, nonatomic) NSDictionary *icons; +@property (strong, nonatomic) NSDictionary *animalsGoneWild; +@property (strong, nonatomic) NSArray *allData; +@end diff --git a/HeadsUpper/HeadsUpper/GameData.m b/HeadsUpper/HeadsUpper/GameData.m new file mode 100644 index 0000000..8a41eea --- /dev/null +++ b/HeadsUpper/HeadsUpper/GameData.m @@ -0,0 +1,29 @@ +// +// GameData.m +// HeadsUpper +// +// Created by Brian Blanco on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import "GameData.h" + +@implementation GameData + +- (instancetype)init +{ + self = [super init]; + if (self) { + _allData = @[@{@"Superstars": @[@"Janet Jackson", @"Leighton Meester", @"Willow Smith", @"Matt Lauer", @"Josh Duhamel", @"Sharon Osbourne", @"Spencer Pratt", @"Demi Moore", @"Whitney Houston", @"Nicole Kidman", @"Miley Cyrus", @"Victoria Beckham", @"LeAnn Rimes", @"Dakota Fanning", @"Dr. Seuss", @"Ryan Phillippe", @"Steve Carell", @"Chris Rock", @"Collin Ferell", @"Drake", @"Rachel McAdams", @"Maya Rudolph"]}, + + @{@"That's so 90's" : @[@"El Niño", @"Viagra", @"Animaniacs", @"League of their Own", @"Happy Gilmore", @"Nick Carter", @"My Heart Will Go On", @"I Know What You Did Last Summer", @"Can You Feel The Love Tonight", @"The Macarana", @"Light-up Sneakers", @"Boy Meets World", @"Baby Got Back", @"Smells Like Teen Spirit", @"Super Soakers", @"7th Heaven", @"Garth Brooks", @"Floppy Discs", @"Kramer", @"Blink 182", @"Surge"]}, + + @{@"Hey Mr. DJ": @[@"\"Girl On Fire\" Alicia Keys", @"\"U Can't Touch This\" MC Hammer", @"\"Hello\" Lionel Richie", @"\"Dark Horse\" Katy Perry", @"\"Someboyd To Love\" Queen", @"\"No Scrubs\" TLC", @"\"Happy\" Pharrell Williams", @"\"Piano Man\" Billy Joel", @"\"Blurred Lines\" Robin Thicke", @"\"Fantasy\" Mariah Carey", @"\"I Will Survive\" Gloria Gaynor", @"\"Come and Get it\" Selena Gomez", @"\"Halo\" Beyonce", @"\"I Believe I Can Fly\" R.Kelly", @"\"The Sign\" Ace of Base", @"\"Diamonds\" Rihanna", @"\"A Thousand Miles\" Vanessa Carlton", @"\"What a Wonderful World\" Louis Armstrong", @"\"We Belong Together\" Mariah Carey", @"\"(I Can't Get No) Satisfaction\""]}, + + @{@"Icons": @[@"Colin Farrell", @"Mozart", @"Billy Joel", @"Judy Garland", @"Napoleon Bonaparte", @"Queen Elizabeth II", @"Fred Armisen", @"Henry Ford", @"Jon Lovitz", @"Julia Child", @"Catherine the Great", @"Magic Johnson", @"Uma Thurman", @"Orson Welles", @"Kathy Bates", @"George Orwell", @"Billy Crystal", @"Farrah Fawcett", @"Gary Busey", @"Chris Farley", @"Tom Selleck", @"Alexander the Great"]}]; + + + } + return self; +} +@end diff --git a/HeadsUpper/HeadsUpper/TitlesTableViewController.h b/HeadsUpper/HeadsUpper/TitlesTableViewController.h new file mode 100644 index 0000000..9fe370e --- /dev/null +++ b/HeadsUpper/HeadsUpper/TitlesTableViewController.h @@ -0,0 +1,14 @@ +// +// TitlesTableViewController.h +// HeadsUpper +// +// Created by Brian Blanco on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import + + +@interface TitlesTableViewController : UITableViewController + +@end diff --git a/HeadsUpper/HeadsUpper/TitlesTableViewController.m b/HeadsUpper/HeadsUpper/TitlesTableViewController.m new file mode 100644 index 0000000..ba0c250 --- /dev/null +++ b/HeadsUpper/HeadsUpper/TitlesTableViewController.m @@ -0,0 +1,64 @@ +// +// TitlesTableViewController.m +// HeadsUpper +// +// Created by Brian Blanco on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import "TitlesTableViewController.h" +#import "GameData.h" + + +@interface TitlesTableViewController () + +@property (nonatomic) NSMutableArray *titleData; +@property (nonatomic) NSArray *titles; +@property (nonatomic) NSMutableDictionary *allTitles; + +@end + +@implementation TitlesTableViewController + + +- (void)viewDidLoad { + [super viewDidLoad]; + + +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return self.titles.count; +} + + + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Title" forIndexPath:indexPath]; + + GameData *titles = [[GameData alloc] init]; + NSString *title = titles.allData[indexPath.row]; + cell.textLabel.text = title; + + return cell; +} + +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ +// if ([segue.identifier isEqualToString:]) { +// <#statements#> +// } +} + +@end diff --git a/HeadsUpper/HeadsUpper/ViewController.m b/HeadsUpper/HeadsUpper/ViewController.m index 14ce57a..241562b 100644 --- a/HeadsUpper/HeadsUpper/ViewController.m +++ b/HeadsUpper/HeadsUpper/ViewController.m @@ -8,6 +8,7 @@ #import "ViewController.h" + @interface ViewController () @end @@ -24,4 +25,9 @@ - (void)didReceiveMemoryWarning { // Dispose of any resources that can be recreated. } +- (void) gameAPI +{ + +} + @end From 9adc96ea1163edbc8f21c36cf50bbc623a5f7158 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 21 Feb 2016 17:25:47 -0500 Subject: [PATCH 2/7] JSON parsed, Tableview Setup --- HeadsUpper/HeadsUpper/GameData.h | 13 ++++--- HeadsUpper/HeadsUpper/GameData.m | 18 ++++----- .../HeadsUpper/TitlesTableViewController.h | 2 + .../HeadsUpper/TitlesTableViewController.m | 37 ++++++++++++++----- 4 files changed, 46 insertions(+), 24 deletions(-) diff --git a/HeadsUpper/HeadsUpper/GameData.h b/HeadsUpper/HeadsUpper/GameData.h index 2fcb99e..1e97d93 100644 --- a/HeadsUpper/HeadsUpper/GameData.h +++ b/HeadsUpper/HeadsUpper/GameData.h @@ -10,10 +10,11 @@ @interface GameData : NSObject -@property (strong, nonatomic) NSDictionary *superstars; -@property (strong, nonatomic) NSDictionary *the90s; -@property (strong, nonatomic) NSDictionary *mrDJ; -@property (strong, nonatomic) NSDictionary *icons; -@property (strong, nonatomic) NSDictionary *animalsGoneWild; -@property (strong, nonatomic) NSArray *allData; +@property (strong, nonatomic) NSString *title; + + +- (id)initWithTitle:(NSString *)title; ++ (id) topicWithTitle:(NSString *)title; + + @end diff --git a/HeadsUpper/HeadsUpper/GameData.m b/HeadsUpper/HeadsUpper/GameData.m index 8a41eea..8f119bd 100644 --- a/HeadsUpper/HeadsUpper/GameData.m +++ b/HeadsUpper/HeadsUpper/GameData.m @@ -10,20 +10,20 @@ @implementation GameData -- (instancetype)init + +- (instancetype)initWithTitle:(NSString *)title { self = [super init]; if (self) { - _allData = @[@{@"Superstars": @[@"Janet Jackson", @"Leighton Meester", @"Willow Smith", @"Matt Lauer", @"Josh Duhamel", @"Sharon Osbourne", @"Spencer Pratt", @"Demi Moore", @"Whitney Houston", @"Nicole Kidman", @"Miley Cyrus", @"Victoria Beckham", @"LeAnn Rimes", @"Dakota Fanning", @"Dr. Seuss", @"Ryan Phillippe", @"Steve Carell", @"Chris Rock", @"Collin Ferell", @"Drake", @"Rachel McAdams", @"Maya Rudolph"]}, - - @{@"That's so 90's" : @[@"El Niño", @"Viagra", @"Animaniacs", @"League of their Own", @"Happy Gilmore", @"Nick Carter", @"My Heart Will Go On", @"I Know What You Did Last Summer", @"Can You Feel The Love Tonight", @"The Macarana", @"Light-up Sneakers", @"Boy Meets World", @"Baby Got Back", @"Smells Like Teen Spirit", @"Super Soakers", @"7th Heaven", @"Garth Brooks", @"Floppy Discs", @"Kramer", @"Blink 182", @"Surge"]}, - - @{@"Hey Mr. DJ": @[@"\"Girl On Fire\" Alicia Keys", @"\"U Can't Touch This\" MC Hammer", @"\"Hello\" Lionel Richie", @"\"Dark Horse\" Katy Perry", @"\"Someboyd To Love\" Queen", @"\"No Scrubs\" TLC", @"\"Happy\" Pharrell Williams", @"\"Piano Man\" Billy Joel", @"\"Blurred Lines\" Robin Thicke", @"\"Fantasy\" Mariah Carey", @"\"I Will Survive\" Gloria Gaynor", @"\"Come and Get it\" Selena Gomez", @"\"Halo\" Beyonce", @"\"I Believe I Can Fly\" R.Kelly", @"\"The Sign\" Ace of Base", @"\"Diamonds\" Rihanna", @"\"A Thousand Miles\" Vanessa Carlton", @"\"What a Wonderful World\" Louis Armstrong", @"\"We Belong Together\" Mariah Carey", @"\"(I Can't Get No) Satisfaction\""]}, - - @{@"Icons": @[@"Colin Farrell", @"Mozart", @"Billy Joel", @"Judy Garland", @"Napoleon Bonaparte", @"Queen Elizabeth II", @"Fred Armisen", @"Henry Ford", @"Jon Lovitz", @"Julia Child", @"Catherine the Great", @"Magic Johnson", @"Uma Thurman", @"Orson Welles", @"Kathy Bates", @"George Orwell", @"Billy Crystal", @"Farrah Fawcett", @"Gary Busey", @"Chris Farley", @"Tom Selleck", @"Alexander the Great"]}]; + self.title = title; - } return self; } + ++ (id)topicWithTitle:(NSString *)title +{ + return [[self alloc] initWithTitle:title]; +} + @end diff --git a/HeadsUpper/HeadsUpper/TitlesTableViewController.h b/HeadsUpper/HeadsUpper/TitlesTableViewController.h index 9fe370e..da10c77 100644 --- a/HeadsUpper/HeadsUpper/TitlesTableViewController.h +++ b/HeadsUpper/HeadsUpper/TitlesTableViewController.h @@ -11,4 +11,6 @@ @interface TitlesTableViewController : UITableViewController +@property (strong, nonatomic) NSMutableArray *topics; + @end diff --git a/HeadsUpper/HeadsUpper/TitlesTableViewController.m b/HeadsUpper/HeadsUpper/TitlesTableViewController.m index ba0c250..cf6070b 100644 --- a/HeadsUpper/HeadsUpper/TitlesTableViewController.m +++ b/HeadsUpper/HeadsUpper/TitlesTableViewController.m @@ -12,10 +12,6 @@ @interface TitlesTableViewController () -@property (nonatomic) NSMutableArray *titleData; -@property (nonatomic) NSArray *titles; -@property (nonatomic) NSMutableDictionary *allTitles; - @end @implementation TitlesTableViewController @@ -24,6 +20,27 @@ @implementation TitlesTableViewController - (void)viewDidLoad { [super viewDidLoad]; + [self fetchHeadsUpperAPI]; +} + +- (void) fetchHeadsUpperAPI +{ + NSURL *topicsURL = [NSURL URLWithString:@"https://heads-up-api.herokuapp.com/"]; + + NSData *jsonData = [NSData dataWithContentsOfURL:topicsURL]; + + NSError *error = nil; + + NSDictionary *topicsDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error]; + + self.topics = [NSMutableArray array]; + + // NSArray *topicsArray = [topicsDictionary objectForKey:@"title"]; + + for (NSDictionary *tDict in topicsDictionary) { + GameData *topic = [GameData topicWithTitle:[tDict objectForKey:@"title"]]; + [self.topics addObject:topic]; + } } @@ -39,18 +56,20 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return self.titles.count; + return self.topics.count; + + } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Title" forIndexPath:indexPath]; + + GameData *topicTitles = [self.topics objectAtIndex:indexPath.row]; - GameData *titles = [[GameData alloc] init]; - NSString *title = titles.allData[indexPath.row]; - cell.textLabel.text = title; - + cell.textLabel.text = topicTitles.title; + return cell; } From d2df2c5df218bf7d6cc8cd8de5010301ee1910d2 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 21 Feb 2016 22:09:00 -0500 Subject: [PATCH 3/7] commit --- .../HeadsUpper.xcodeproj/project.pbxproj | 12 ++++----- .../HeadsUpper/Base.lproj/Main.storyboard | 27 ++++++++++++++++--- HeadsUpper/HeadsUpper/GameData.h | 2 +- ...{ViewController.h => GameViewController.h} | 4 +-- ...{ViewController.m => GameViewController.m} | 15 ++++++----- .../HeadsUpper/TitlesTableViewController.h | 2 ++ .../HeadsUpper/TitlesTableViewController.m | 12 +++++---- 7 files changed, 50 insertions(+), 24 deletions(-) rename HeadsUpper/HeadsUpper/{ViewController.h => GameViewController.h} (66%) rename HeadsUpper/HeadsUpper/{ViewController.m => GameViewController.m} (69%) diff --git a/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj b/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj index 652338d..64353cf 100644 --- a/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj +++ b/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj @@ -11,7 +11,7 @@ 5A4C555A1C7A62A70098B1B6 /* GameData.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A4C55591C7A62A70098B1B6 /* GameData.m */; }; 8D89695C1C755D0200D32E8A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D89695B1C755D0200D32E8A /* main.m */; }; 8D89695F1C755D0200D32E8A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D89695E1C755D0200D32E8A /* AppDelegate.m */; }; - 8D8969621C755D0200D32E8A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D8969611C755D0200D32E8A /* ViewController.m */; }; + 8D8969621C755D0200D32E8A /* GameViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D8969611C755D0200D32E8A /* GameViewController.m */; }; 8D8969651C755D0200D32E8A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8D8969631C755D0200D32E8A /* Main.storyboard */; }; 8D8969671C755D0200D32E8A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8D8969661C755D0200D32E8A /* Assets.xcassets */; }; 8D89696A1C755D0200D32E8A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8D8969681C755D0200D32E8A /* LaunchScreen.storyboard */; }; @@ -26,8 +26,8 @@ 8D89695B1C755D0200D32E8A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 8D89695D1C755D0200D32E8A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 8D89695E1C755D0200D32E8A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 8D8969601C755D0200D32E8A /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; - 8D8969611C755D0200D32E8A /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 8D8969601C755D0200D32E8A /* GameViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GameViewController.h; sourceTree = ""; }; + 8D8969611C755D0200D32E8A /* GameViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GameViewController.m; sourceTree = ""; }; 8D8969641C755D0200D32E8A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 8D8969661C755D0200D32E8A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 8D8969691C755D0200D32E8A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; @@ -66,8 +66,8 @@ children = ( 8D89695D1C755D0200D32E8A /* AppDelegate.h */, 8D89695E1C755D0200D32E8A /* AppDelegate.m */, - 8D8969601C755D0200D32E8A /* ViewController.h */, - 8D8969611C755D0200D32E8A /* ViewController.m */, + 8D8969601C755D0200D32E8A /* GameViewController.h */, + 8D8969611C755D0200D32E8A /* GameViewController.m */, 5A3055D31C7A430D00100C42 /* TitlesTableViewController.h */, 5A3055D41C7A430E00100C42 /* TitlesTableViewController.m */, 5A4C55581C7A62A70098B1B6 /* GameData.h */, @@ -159,7 +159,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8D8969621C755D0200D32E8A /* ViewController.m in Sources */, + 8D8969621C755D0200D32E8A /* GameViewController.m in Sources */, 5A4C555A1C7A62A70098B1B6 /* GameData.m in Sources */, 8D89695F1C755D0200D32E8A /* AppDelegate.m in Sources */, 5A3055D51C7A430E00100C42 /* TitlesTableViewController.m in Sources */, diff --git a/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard b/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard index 73a6bed..7307111 100644 --- a/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard +++ b/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard @@ -3,6 +3,7 @@ + @@ -22,7 +23,7 @@ - + @@ -37,10 +38,10 @@ - + - + @@ -48,8 +49,28 @@ + + + + + + + + + + diff --git a/HeadsUpper/HeadsUpper/GameData.h b/HeadsUpper/HeadsUpper/GameData.h index 1e97d93..168d877 100644 --- a/HeadsUpper/HeadsUpper/GameData.h +++ b/HeadsUpper/HeadsUpper/GameData.h @@ -11,7 +11,7 @@ @interface GameData : NSObject @property (strong, nonatomic) NSString *title; - +@property (strong, nonatomic) NSString *subject; - (id)initWithTitle:(NSString *)title; + (id) topicWithTitle:(NSString *)title; diff --git a/HeadsUpper/HeadsUpper/ViewController.h b/HeadsUpper/HeadsUpper/GameViewController.h similarity index 66% rename from HeadsUpper/HeadsUpper/ViewController.h rename to HeadsUpper/HeadsUpper/GameViewController.h index 65d6cf5..7091e59 100644 --- a/HeadsUpper/HeadsUpper/ViewController.h +++ b/HeadsUpper/HeadsUpper/GameViewController.h @@ -8,8 +8,8 @@ #import -@interface ViewController : UIViewController - +@interface GameViewController : UIViewController +//@property (strong, nonatomic) NSArray * @end diff --git a/HeadsUpper/HeadsUpper/ViewController.m b/HeadsUpper/HeadsUpper/GameViewController.m similarity index 69% rename from HeadsUpper/HeadsUpper/ViewController.m rename to HeadsUpper/HeadsUpper/GameViewController.m index 241562b..6c06033 100644 --- a/HeadsUpper/HeadsUpper/ViewController.m +++ b/HeadsUpper/HeadsUpper/GameViewController.m @@ -6,18 +6,22 @@ // Copyright © 2016 Michael Kavouras. All rights reserved. // -#import "ViewController.h" +#import "GameViewController.h" -@interface ViewController () +@interface GameViewController () + +@property (weak, nonatomic) IBOutlet UILabel *gameLabel; @end -@implementation ViewController +@implementation GameViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. + + self.gameLabel.text = @"Aye"; } - (void)didReceiveMemoryWarning { @@ -25,9 +29,6 @@ - (void)didReceiveMemoryWarning { // Dispose of any resources that can be recreated. } -- (void) gameAPI -{ - -} + @end diff --git a/HeadsUpper/HeadsUpper/TitlesTableViewController.h b/HeadsUpper/HeadsUpper/TitlesTableViewController.h index da10c77..58bf4b3 100644 --- a/HeadsUpper/HeadsUpper/TitlesTableViewController.h +++ b/HeadsUpper/HeadsUpper/TitlesTableViewController.h @@ -12,5 +12,7 @@ @interface TitlesTableViewController : UITableViewController @property (strong, nonatomic) NSMutableArray *topics; +@property (strong, nonatomic) NSMutableArray *subjects; +@property (strong, nonatomic) NSMutableDictionary *allStuff; @end diff --git a/HeadsUpper/HeadsUpper/TitlesTableViewController.m b/HeadsUpper/HeadsUpper/TitlesTableViewController.m index cf6070b..ef9b89c 100644 --- a/HeadsUpper/HeadsUpper/TitlesTableViewController.m +++ b/HeadsUpper/HeadsUpper/TitlesTableViewController.m @@ -33,12 +33,14 @@ - (void) fetchHeadsUpperAPI NSDictionary *topicsDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error]; + self.topics = [NSMutableArray array]; // NSArray *topicsArray = [topicsDictionary objectForKey:@"title"]; for (NSDictionary *tDict in topicsDictionary) { GameData *topic = [GameData topicWithTitle:[tDict objectForKey:@"title"]]; + topic.subject = [tDict objectForKey:@"subjects"]; [self.topics addObject:topic]; } @@ -57,8 +59,6 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.topics.count; - - } @@ -75,9 +75,11 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { -// if ([segue.identifier isEqualToString:]) { -// <#statements#> -// } + if ([segue.identifier isEqualToString:@"showGame"]) { + NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; + + + } } @end From 9b93acce6f52b1fc3165a52eaf0bfbc52634c216 Mon Sep 17 00:00:00 2001 From: Brian Date: Sun, 21 Feb 2016 23:58:14 -0500 Subject: [PATCH 4/7] randomized subjects --- HeadsUpper/HeadsUpper/GameData.h | 2 +- HeadsUpper/HeadsUpper/GameViewController.h | 6 +++++- HeadsUpper/HeadsUpper/GameViewController.m | 14 +++++++++++++- HeadsUpper/HeadsUpper/TitlesTableViewController.m | 6 ++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/HeadsUpper/HeadsUpper/GameData.h b/HeadsUpper/HeadsUpper/GameData.h index 168d877..eebf371 100644 --- a/HeadsUpper/HeadsUpper/GameData.h +++ b/HeadsUpper/HeadsUpper/GameData.h @@ -11,7 +11,7 @@ @interface GameData : NSObject @property (strong, nonatomic) NSString *title; -@property (strong, nonatomic) NSString *subject; +@property (strong, nonatomic) NSArray *subject; - (id)initWithTitle:(NSString *)title; + (id) topicWithTitle:(NSString *)title; diff --git a/HeadsUpper/HeadsUpper/GameViewController.h b/HeadsUpper/HeadsUpper/GameViewController.h index 7091e59..960b537 100644 --- a/HeadsUpper/HeadsUpper/GameViewController.h +++ b/HeadsUpper/HeadsUpper/GameViewController.h @@ -7,9 +7,13 @@ // #import +#import "GameData.h" @interface GameViewController : UIViewController -//@property (strong, nonatomic) NSArray * +@property (strong, nonatomic)NSString *category; +@property (strong, nonatomic)GameData *data; + + @end diff --git a/HeadsUpper/HeadsUpper/GameViewController.m b/HeadsUpper/HeadsUpper/GameViewController.m index 6c06033..927a77a 100644 --- a/HeadsUpper/HeadsUpper/GameViewController.m +++ b/HeadsUpper/HeadsUpper/GameViewController.m @@ -21,7 +21,19 @@ - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. - self.gameLabel.text = @"Aye"; + // self.gameLabel.text = self.category; + [self randomClue]; +} + +-(void) randomClue +{ + NSUInteger suffleSubjects = arc4random_uniform(self.data.subject.count); + + NSString *shuffledSubject = [self.data.subject objectAtIndex: suffleSubjects]; + + self.gameLabel.text = shuffledSubject; + + } - (void)didReceiveMemoryWarning { diff --git a/HeadsUpper/HeadsUpper/TitlesTableViewController.m b/HeadsUpper/HeadsUpper/TitlesTableViewController.m index ef9b89c..9cca3ae 100644 --- a/HeadsUpper/HeadsUpper/TitlesTableViewController.m +++ b/HeadsUpper/HeadsUpper/TitlesTableViewController.m @@ -8,6 +8,7 @@ #import "TitlesTableViewController.h" #import "GameData.h" +#import "GameViewController.h" @interface TitlesTableViewController () @@ -78,7 +79,12 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender if ([segue.identifier isEqualToString:@"showGame"]) { NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; + GameData *topicData = self.topics[indexPath.row]; + GameViewController *viewController = segue.destinationViewController; + + viewController.data = topicData; + viewController.category = topicData.title; } } From 06bb7a11414c40cbd531b84e847b97fc7c5ca835 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 22 Feb 2016 01:27:47 -0500 Subject: [PATCH 5/7] commit --- .../HeadsUpper/Base.lproj/Main.storyboard | 24 +++++++++---- HeadsUpper/HeadsUpper/GameViewController.m | 34 +++++++++++++++++-- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard b/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard index 7307111..895d672 100644 --- a/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard +++ b/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard @@ -4,6 +4,7 @@ + @@ -50,26 +51,35 @@ - - - + + + + + + + diff --git a/HeadsUpper/HeadsUpper/GameViewController.m b/HeadsUpper/HeadsUpper/GameViewController.m index 927a77a..d4c0afc 100644 --- a/HeadsUpper/HeadsUpper/GameViewController.m +++ b/HeadsUpper/HeadsUpper/GameViewController.m @@ -12,6 +12,9 @@ @interface GameViewController () @property (weak, nonatomic) IBOutlet UILabel *gameLabel; +@property (weak, nonatomic) IBOutlet UILabel *timerLabel; +@property (nonatomic) NSUInteger count; +@property (nonatomic) NSTimer *countDown; @end @@ -23,19 +26,46 @@ - (void)viewDidLoad { // self.gameLabel.text = self.category; [self randomClue]; + [self timerCountDown]; + } -(void) randomClue { - NSUInteger suffleSubjects = arc4random_uniform(self.data.subject.count); + NSUInteger shuffleSubjects = arc4random_uniform(self.data.subject.count); - NSString *shuffledSubject = [self.data.subject objectAtIndex: suffleSubjects]; + NSString *shuffledSubject = [self.data.subject objectAtIndex: shuffleSubjects]; self.gameLabel.text = shuffledSubject; } +-(void) timerCountDown +{ + self.count = 20; + self.countDown = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(startCounting) userInfo:nil repeats:YES]; +} + +-(void)startCounting +{ + self.count--; + self.timerLabel.text = [NSString stringWithFormat:@"%i", self.count]; + + if (self.count == 0) { + [self.countDown invalidate]; + + UIAlertView *alert = [[UIAlertView alloc] + initWithTitle:@"Game Over" + message:nil + delegate:self + cancelButtonTitle:@"Done" + otherButtonTitles:nil]; + + [alert show]; + } + +} - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. From bd30240139cf7ff46d985b67e46814a600bb1971 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 22 Feb 2016 02:29:47 -0500 Subject: [PATCH 6/7] commit --- HeadsUpper/HeadsUpper/GameViewController.m | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/HeadsUpper/HeadsUpper/GameViewController.m b/HeadsUpper/HeadsUpper/GameViewController.m index d4c0afc..ea2e0dd 100644 --- a/HeadsUpper/HeadsUpper/GameViewController.m +++ b/HeadsUpper/HeadsUpper/GameViewController.m @@ -27,7 +27,7 @@ - (void)viewDidLoad { // self.gameLabel.text = self.category; [self randomClue]; [self timerCountDown]; - + } -(void) randomClue @@ -63,9 +63,28 @@ -(void)startCounting otherButtonTitles:nil]; [alert show]; + + } + +} + +/* found resource here http://stackoverflow.com/questions/25806040/how-to-unwind-segues-from-uialertview-button */ +- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex +{ + //Using buttonIndex you could find whether OK or CANCEL is pressed and perform your popToRootViewController call. + //Below on OK press then moving to root VC + if (buttonIndex==0) + { + //OK is pressed... + [self.navigationController popToRootViewControllerAnimated:YES]; } +} + +-(void)gestures +{ } + - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. From 6ef5def7a42eb9232940035f05fbca05de3f089b Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 22 Feb 2016 11:48:25 -0500 Subject: [PATCH 7/7] commit --- .../HeadsUpper.xcodeproj/project.pbxproj | 6 ++ .../HeadsUpper/Base.lproj/Main.storyboard | 6 +- HeadsUpper/HeadsUpper/GameViewController.h | 3 + HeadsUpper/HeadsUpper/GameViewController.m | 68 +++++++++++++++---- HeadsUpper/HeadsUpper/GestureManager.h | 17 +++++ HeadsUpper/HeadsUpper/GestureManager.m | 53 +++++++++++++++ .../HeadsUpper/TitlesTableViewController.h | 1 - 7 files changed, 137 insertions(+), 17 deletions(-) create mode 100644 HeadsUpper/HeadsUpper/GestureManager.h create mode 100644 HeadsUpper/HeadsUpper/GestureManager.m diff --git a/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj b/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj index 64353cf..b457a85 100644 --- a/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj +++ b/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 5A3055D51C7A430E00100C42 /* TitlesTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A3055D41C7A430E00100C42 /* TitlesTableViewController.m */; }; + 5A3591E91C7AF5E400546A0B /* GestureManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A3591E81C7AF5E400546A0B /* GestureManager.m */; }; 5A4C555A1C7A62A70098B1B6 /* GameData.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A4C55591C7A62A70098B1B6 /* GameData.m */; }; 8D89695C1C755D0200D32E8A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D89695B1C755D0200D32E8A /* main.m */; }; 8D89695F1C755D0200D32E8A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D89695E1C755D0200D32E8A /* AppDelegate.m */; }; @@ -20,6 +21,8 @@ /* Begin PBXFileReference section */ 5A3055D31C7A430D00100C42 /* TitlesTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TitlesTableViewController.h; sourceTree = ""; }; 5A3055D41C7A430E00100C42 /* TitlesTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TitlesTableViewController.m; sourceTree = ""; }; + 5A3591E71C7AF5E400546A0B /* GestureManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GestureManager.h; sourceTree = ""; }; + 5A3591E81C7AF5E400546A0B /* GestureManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GestureManager.m; sourceTree = ""; }; 5A4C55581C7A62A70098B1B6 /* GameData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameData.h; sourceTree = ""; }; 5A4C55591C7A62A70098B1B6 /* GameData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameData.m; sourceTree = ""; }; 8D8969571C755D0200D32E8A /* HeadsUpper.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HeadsUpper.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -70,6 +73,8 @@ 8D8969611C755D0200D32E8A /* GameViewController.m */, 5A3055D31C7A430D00100C42 /* TitlesTableViewController.h */, 5A3055D41C7A430E00100C42 /* TitlesTableViewController.m */, + 5A3591E71C7AF5E400546A0B /* GestureManager.h */, + 5A3591E81C7AF5E400546A0B /* GestureManager.m */, 5A4C55581C7A62A70098B1B6 /* GameData.h */, 5A4C55591C7A62A70098B1B6 /* GameData.m */, 8D8969631C755D0200D32E8A /* Main.storyboard */, @@ -160,6 +165,7 @@ buildActionMask = 2147483647; files = ( 8D8969621C755D0200D32E8A /* GameViewController.m in Sources */, + 5A3591E91C7AF5E400546A0B /* GestureManager.m in Sources */, 5A4C555A1C7A62A70098B1B6 /* GameData.m in Sources */, 8D89695F1C755D0200D32E8A /* AppDelegate.m in Sources */, 5A3055D51C7A430E00100C42 /* TitlesTableViewController.m in Sources */, diff --git a/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard b/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard index 895d672..645c3f6 100644 --- a/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard +++ b/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard @@ -56,13 +56,13 @@ - + diff --git a/HeadsUpper/HeadsUpper/GameViewController.h b/HeadsUpper/HeadsUpper/GameViewController.h index 960b537..f316519 100644 --- a/HeadsUpper/HeadsUpper/GameViewController.h +++ b/HeadsUpper/HeadsUpper/GameViewController.h @@ -13,7 +13,10 @@ @property (strong, nonatomic)NSString *category; @property (strong, nonatomic)GameData *data; +@property (nonatomic) NSUInteger correct; +@property (nonatomic) NSUInteger incorrect; +-(void) randomClue; @end diff --git a/HeadsUpper/HeadsUpper/GameViewController.m b/HeadsUpper/HeadsUpper/GameViewController.m index ea2e0dd..1bc7bc0 100644 --- a/HeadsUpper/HeadsUpper/GameViewController.m +++ b/HeadsUpper/HeadsUpper/GameViewController.m @@ -13,7 +13,10 @@ @interface GameViewController () @property (weak, nonatomic) IBOutlet UILabel *gameLabel; @property (weak, nonatomic) IBOutlet UILabel *timerLabel; +@property (nonatomic) NSString *message; @property (nonatomic) NSUInteger count; +@property (nonatomic) NSUInteger totalScore; + @property (nonatomic) NSTimer *countDown; @end @@ -22,14 +25,58 @@ @implementation GameViewController - (void)viewDidLoad { [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. - // self.gameLabel.text = self.category; [self randomClue]; [self timerCountDown]; } +- (void)viewDidAppear:(BOOL)animated +{ + [self gestures]; +} + +- (void)gestures +{ + UISwipeGestureRecognizer *left = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipManager:)]; + left.direction = UISwipeGestureRecognizerDirectionLeft; + + UISwipeGestureRecognizer *right = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipManager:)]; + right.direction = UISwipeGestureRecognizerDirectionRight; + + + [self.view addGestureRecognizer:left]; + [self.view addGestureRecognizer:right]; + +} + +- (void)swipManager:(UISwipeGestureRecognizer *)gesture +{ + switch (gesture.direction) { + case UISwipeGestureRecognizerDirectionRight: + self.view.backgroundColor = [UIColor redColor]; + self.correct++; + [self randomClue]; + break; + case UISwipeGestureRecognizerDirectionLeft: + self.view.backgroundColor = [UIColor greenColor]; + self.incorrect++; + [self randomClue]; + break; + + + default: + return; + + } +} + +-(NSString *)scoreKeeper +{ + self.totalScore = self.correct + self.incorrect; + return self.message = [NSString stringWithFormat:@"%i/%i", self.correct, self.incorrect]; +} + -(void) randomClue { NSUInteger shuffleSubjects = arc4random_uniform(self.data.subject.count); @@ -44,7 +91,11 @@ -(void) randomClue -(void) timerCountDown { self.count = 20; - self.countDown = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(startCounting) userInfo:nil repeats:YES]; + self.countDown = [NSTimer scheduledTimerWithTimeInterval:1.0 + target:self + selector:@selector(startCounting) + userInfo:nil + repeats:YES]; } -(void)startCounting @@ -57,7 +108,7 @@ -(void)startCounting UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Game Over" - message:nil + message:self.scoreKeeper delegate:self cancelButtonTitle:@"Done" otherButtonTitles:nil]; @@ -80,15 +131,6 @@ - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)butto } } --(void)gestures -{ - -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} diff --git a/HeadsUpper/HeadsUpper/GestureManager.h b/HeadsUpper/HeadsUpper/GestureManager.h new file mode 100644 index 0000000..3733d78 --- /dev/null +++ b/HeadsUpper/HeadsUpper/GestureManager.h @@ -0,0 +1,17 @@ +// +// GestureManager.h +// HeadsUpper +// +// Created by Brian Blanco on 2/22/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import +#import + +@interface GestureManager : NSObject + +- (void)gestures; +- (void)swipManager:(UISwipeGestureRecognizer *)gesture; + +@end diff --git a/HeadsUpper/HeadsUpper/GestureManager.m b/HeadsUpper/HeadsUpper/GestureManager.m new file mode 100644 index 0000000..48bb771 --- /dev/null +++ b/HeadsUpper/HeadsUpper/GestureManager.m @@ -0,0 +1,53 @@ +// +// GestureManager.m +// HeadsUpper +// +// Created by Brian Blanco on 2/22/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import "GestureManager.h" +#import "GameViewController.h" + +@implementation GestureManager + +- (void)gestures +{ + GameViewController *vc = [[GameViewController alloc] init]; + UISwipeGestureRecognizer *left = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipManager:)]; + left.direction = UISwipeGestureRecognizerDirectionLeft; + + UISwipeGestureRecognizer *right = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipManager:)]; + right.direction = UISwipeGestureRecognizerDirectionRight; + + + [vc.view addGestureRecognizer:left]; + [vc.view addGestureRecognizer:right]; + +} + +- (void)swipManager:(UISwipeGestureRecognizer *)gesture +{ + GameViewController *vc = [[GameViewController alloc] init]; + switch (gesture.direction) { + case UISwipeGestureRecognizerDirectionRight: + vc.view.backgroundColor = [UIColor redColor]; + vc.correct++; + [vc randomClue]; + break; + case UISwipeGestureRecognizerDirectionLeft: + vc.view.backgroundColor = [UIColor greenColor]; + vc.incorrect++; + [vc randomClue]; + break; + + + default: + return; + + } +} + + + +@end diff --git a/HeadsUpper/HeadsUpper/TitlesTableViewController.h b/HeadsUpper/HeadsUpper/TitlesTableViewController.h index 58bf4b3..c2d9872 100644 --- a/HeadsUpper/HeadsUpper/TitlesTableViewController.h +++ b/HeadsUpper/HeadsUpper/TitlesTableViewController.h @@ -13,6 +13,5 @@ @property (strong, nonatomic) NSMutableArray *topics; @property (strong, nonatomic) NSMutableArray *subjects; -@property (strong, nonatomic) NSMutableDictionary *allStuff; @end