diff --git a/OptionSelector.xcodeproj/project.pbxproj b/OptionSelector.xcodeproj/project.pbxproj index 1788504..2220292 100644 --- a/OptionSelector.xcodeproj/project.pbxproj +++ b/OptionSelector.xcodeproj/project.pbxproj @@ -7,9 +7,12 @@ objects = { /* Begin PBXBuildFile section */ + 3DA24BD11B7AD088002076F1 /* MainList.m in Sources */ = {isa = PBXBuildFile; fileRef = 3DA24BD01B7AD088002076F1 /* MainList.m */; }; + 3DA24BD41B7AD1A5002076F1 /* SubList.m in Sources */ = {isa = PBXBuildFile; fileRef = 3DA24BD31B7AD1A5002076F1 /* SubList.m */; }; + 3DA24BD71B7AD223002076F1 /* ObjectsInsideLists.m in Sources */ = {isa = PBXBuildFile; fileRef = 3DA24BD61B7AD223002076F1 /* ObjectsInsideLists.m */; }; + 3DCCBC9B1B7AE12D00010417 /* CQCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 3DCCBC9A1B7AE12D00010417 /* CQCategory.m */; }; 8DECE7921B78082B0064D760 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DECE7911B78082B0064D760 /* main.m */; }; 8DECE7951B78082B0064D760 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DECE7941B78082B0064D760 /* AppDelegate.m */; }; - 8DECE7981B78082B0064D760 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DECE7971B78082B0064D760 /* ViewController.m */; }; 8DECE79B1B78082B0064D760 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8DECE7991B78082B0064D760 /* Main.storyboard */; }; 8DECE79D1B78082B0064D760 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8DECE79C1B78082B0064D760 /* Images.xcassets */; }; 8DECE7A01B78082B0064D760 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8DECE79E1B78082B0064D760 /* LaunchScreen.xib */; }; @@ -27,13 +30,19 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 3DA24BCF1B7AD088002076F1 /* MainList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainList.h; sourceTree = ""; }; + 3DA24BD01B7AD088002076F1 /* MainList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainList.m; sourceTree = ""; }; + 3DA24BD21B7AD1A5002076F1 /* SubList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SubList.h; sourceTree = ""; }; + 3DA24BD31B7AD1A5002076F1 /* SubList.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SubList.m; sourceTree = ""; }; + 3DA24BD51B7AD223002076F1 /* ObjectsInsideLists.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectsInsideLists.h; sourceTree = ""; }; + 3DA24BD61B7AD223002076F1 /* ObjectsInsideLists.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjectsInsideLists.m; sourceTree = ""; }; + 3DCCBC991B7AE12D00010417 /* CQCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CQCategory.h; sourceTree = ""; }; + 3DCCBC9A1B7AE12D00010417 /* CQCategory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CQCategory.m; sourceTree = ""; }; 8DECE78C1B78082B0064D760 /* OptionSelector.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OptionSelector.app; sourceTree = BUILT_PRODUCTS_DIR; }; 8DECE7901B78082B0064D760 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 8DECE7911B78082B0064D760 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 8DECE7931B78082B0064D760 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 8DECE7941B78082B0064D760 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 8DECE7961B78082B0064D760 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; - 8DECE7971B78082B0064D760 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 8DECE79A1B78082B0064D760 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 8DECE79C1B78082B0064D760 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 8DECE79F1B78082B0064D760 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; @@ -83,8 +92,14 @@ children = ( 8DECE7931B78082B0064D760 /* AppDelegate.h */, 8DECE7941B78082B0064D760 /* AppDelegate.m */, - 8DECE7961B78082B0064D760 /* ViewController.h */, - 8DECE7971B78082B0064D760 /* ViewController.m */, + 3DA24BD51B7AD223002076F1 /* ObjectsInsideLists.h */, + 3DA24BD61B7AD223002076F1 /* ObjectsInsideLists.m */, + 3DCCBC991B7AE12D00010417 /* CQCategory.h */, + 3DCCBC9A1B7AE12D00010417 /* CQCategory.m */, + 3DA24BCF1B7AD088002076F1 /* MainList.h */, + 3DA24BD01B7AD088002076F1 /* MainList.m */, + 3DA24BD21B7AD1A5002076F1 /* SubList.h */, + 3DA24BD31B7AD1A5002076F1 /* SubList.m */, 8DECE7991B78082B0064D760 /* Main.storyboard */, 8DECE79C1B78082B0064D760 /* Images.xcassets */, 8DECE79E1B78082B0064D760 /* LaunchScreen.xib */, @@ -219,9 +234,12 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8DECE7981B78082B0064D760 /* ViewController.m in Sources */, + 3DA24BD11B7AD088002076F1 /* MainList.m in Sources */, + 3DCCBC9B1B7AE12D00010417 /* CQCategory.m in Sources */, 8DECE7951B78082B0064D760 /* AppDelegate.m in Sources */, + 3DA24BD41B7AD1A5002076F1 /* SubList.m in Sources */, 8DECE7921B78082B0064D760 /* main.m in Sources */, + 3DA24BD71B7AD223002076F1 /* ObjectsInsideLists.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -378,6 +396,7 @@ "$(inherited)", ); INFOPLIST_FILE = OptionSelectorTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.3; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/OptionSelector.app/OptionSelector"; @@ -393,6 +412,7 @@ "$(inherited)", ); INFOPLIST_FILE = OptionSelectorTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.3; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/OptionSelector.app/OptionSelector"; @@ -418,6 +438,7 @@ 8DECE7B11B78082B0064D760 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 8DECE7B21B78082B0064D760 /* Build configuration list for PBXNativeTarget "OptionSelectorTests" */ = { isa = XCConfigurationList; @@ -426,6 +447,7 @@ 8DECE7B41B78082B0064D760 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/OptionSelector/Base.lproj/Main.storyboard b/OptionSelector/Base.lproj/Main.storyboard index d912f9d..16e8e35 100644 --- a/OptionSelector/Base.lproj/Main.storyboard +++ b/OptionSelector/Base.lproj/Main.storyboard @@ -1,25 +1,104 @@ - + - + - - + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OptionSelector/CQCategory.h b/OptionSelector/CQCategory.h new file mode 100644 index 0000000..0027286 --- /dev/null +++ b/OptionSelector/CQCategory.h @@ -0,0 +1,17 @@ +// +// CQCategory.h +// OptionSelector +// +// Created by Fatima Zenine Villanueva on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface CQCategory : NSObject + +@property (nonatomic) NSString *name; +@property (nonatomic) NSArray *options; +@property (nonatomic) NSString *selection; + +@end diff --git a/OptionSelector/CQCategory.m b/OptionSelector/CQCategory.m new file mode 100644 index 0000000..3edce13 --- /dev/null +++ b/OptionSelector/CQCategory.m @@ -0,0 +1,13 @@ +// +// CQCategory.m +// OptionSelector +// +// Created by Fatima Zenine Villanueva on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "CQCategory.h" + +@implementation CQCategory + +@end diff --git a/OptionSelector/MainList.h b/OptionSelector/MainList.h new file mode 100644 index 0000000..a689816 --- /dev/null +++ b/OptionSelector/MainList.h @@ -0,0 +1,16 @@ +// +// MainList.h +// OptionSelector +// +// Created by Fatima Zenine Villanueva on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import +#import "CQCategory.h" + +@interface MainList : UITableViewController + +@property (nonatomic) CQCategory *mainCQ; + +@end diff --git a/OptionSelector/MainList.m b/OptionSelector/MainList.m new file mode 100644 index 0000000..606b200 --- /dev/null +++ b/OptionSelector/MainList.m @@ -0,0 +1,62 @@ +// +// MainList.m +// OptionSelector +// +// Created by Fatima Zenine Villanueva on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "MainList.h" +#import "ObjectsInsideLists.h" +#import "CQCategory.h" +#import "SubList.h" + +@interface MainList () + +@property (nonatomic) ObjectsInsideLists *model; + +@end + +@implementation MainList + +- (void)viewDidLoad { + [super viewDidLoad]; + // loads the model with data from ObjectsInsideLists + self.model = [[ObjectsInsideLists alloc]init]; +} + +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + [self.tableView reloadData]; +} + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return self.model.videoGames.count; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MainListID" forIndexPath:indexPath]; + CQCategory *category = self.model.videoGames[indexPath.row]; + cell.textLabel.text = category.name; + cell.detailTextLabel.text= category.selection; + return cell; +} + +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + NSLog(@"Preparing for Segue"); + if([segue.identifier isEqualToString:@"SubListSegue"]) + { + NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; + SubList *sublistVC = segue.destinationViewController; + CQCategory *category = self.model.videoGames[indexPath.row]; + sublistVC.title = category.name; + sublistVC.sublistCQ = [self.model.videoGames objectAtIndex:indexPath.row]; + NSLog(@"%@", sublistVC.sublistCQ.options); + } +} + +@end diff --git a/OptionSelector/ObjectsInsideLists.h b/OptionSelector/ObjectsInsideLists.h new file mode 100644 index 0000000..c37ba3a --- /dev/null +++ b/OptionSelector/ObjectsInsideLists.h @@ -0,0 +1,15 @@ +// +// ObjectsInsideLists.h +// OptionSelector +// +// Created by Fatima Zenine Villanueva on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface ObjectsInsideLists : NSObject + +@property (nonatomic) NSArray *videoGames; + +@end diff --git a/OptionSelector/ObjectsInsideLists.m b/OptionSelector/ObjectsInsideLists.m new file mode 100644 index 0000000..bebcd0e --- /dev/null +++ b/OptionSelector/ObjectsInsideLists.m @@ -0,0 +1,69 @@ +// +// ObjectsInsideLists.m +// OptionSelector +// +// Created by Fatima Zenine Villanueva on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "ObjectsInsideLists.h" +#import "CQCategory.h" + +@implementation ObjectsInsideLists + +-(instancetype)init { + if (self = [super init]) { + self.videoGames = [self arrayOfGames]; + return self; + } + return nil; +} + +-(NSArray *)arrayOfGames { + NSArray *horror = @[ + @"Alan Wake", + @"Alien", + @"Condemned", + @"Dead Rising", + @"Dead Space", + @"Dino Crisis", + @"Five Night At Freddy's", + @"Obscure", + @"Resident Evil", + @"Silent Hill", + ]; + + NSArray *shooter = @[ + @"Battlefield", + @"Call of Duty", + @"Counter-Strike", + @"Half-Life", + @"Wolfenstein", + ]; + + NSArray *adventure = @[ + @"Final Fantasy", + @"Grim Fandango", + @"King's Quest", + @"Legend of Zelda", + @"Pokemon", + @"Shadow of the Colossus", + @"The Longest Journey" + ]; + + CQCategory *adventureCategory = [[CQCategory alloc] init]; + adventureCategory.name = @"Adventure"; + adventureCategory.options = adventure; + + CQCategory *horrorCategory = [[CQCategory alloc] init]; + horrorCategory.name = @"Horror"; + horrorCategory.options = horror; + + CQCategory *shooterCategory = [[CQCategory alloc]init]; + shooterCategory.name = @"Shooter"; + shooterCategory.options = shooter; + + return @[adventureCategory, horrorCategory, shooterCategory]; + +} +@end diff --git a/OptionSelector/SubList.h b/OptionSelector/SubList.h new file mode 100644 index 0000000..4798812 --- /dev/null +++ b/OptionSelector/SubList.h @@ -0,0 +1,16 @@ +// +// SubList.h +// OptionSelector +// +// Created by Fatima Zenine Villanueva on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import +#import "CQCategory.h" + +@interface SubList : UITableViewController + +@property (nonatomic) CQCategory *sublistCQ; + +@end diff --git a/OptionSelector/SubList.m b/OptionSelector/SubList.m new file mode 100644 index 0000000..a398002 --- /dev/null +++ b/OptionSelector/SubList.m @@ -0,0 +1,66 @@ +// +// SubList.m +// OptionSelector +// +// Created by Fatima Zenine Villanueva on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "SubList.h" +#import "MainList.h" +#import "CQCategory.h" +#import "ObjectsInsideLists.h" + +@interface SubList () +@end + +@implementation SubList + +- (void)viewDidLoad { + [super viewDidLoad]; + + // creates a BACK button + UIBarButtonItem *buttonizeButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" + style:UIBarButtonItemStyleDone + target:self + action:@selector(buttonizeButtonTap:)]; + self.navigationItem.hidesBackButton = YES; + self.navigationItem.leftBarButtonItem = buttonizeButton; +} + +// method connected to the instatiated button +-(void)buttonizeButtonTap:(id)sender { + // pushes to the root view controller + [self.navigationController popToRootViewControllerAnimated:YES]; +} + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; + // returns only 1 section +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return self.sublistCQ.options.count; + // returns the number of items inside the selected array +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SubListID" forIndexPath:indexPath]; + cell.textLabel.text = self.sublistCQ.options[indexPath.row]; + return cell; + // grabs the string of the selected object and returns the cell +} + +// method tha creates a checkmark when selected +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ + [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark; + // on selected-- it sets the string 'selection' property of sublistCQ + self.sublistCQ.selection = self.sublistCQ.options[indexPath.row]; +} + +// unchecks the non-selected row +-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{ + [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryNone; +} + +@end diff --git a/OptionSelector/ViewController.h b/OptionSelector/ViewController.h deleted file mode 100644 index 6b5159f..0000000 --- a/OptionSelector/ViewController.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// ViewController.h -// OptionSelector -// -// Created by Michael Kavouras on 8/9/15. -// Copyright (c) 2015 Mike Kavouras. All rights reserved. -// - -#import - -@interface ViewController : UIViewController - - -@end - diff --git a/OptionSelector/ViewController.m b/OptionSelector/ViewController.m deleted file mode 100644 index 8c74bbb..0000000 --- a/OptionSelector/ViewController.m +++ /dev/null @@ -1,27 +0,0 @@ -// -// ViewController.m -// OptionSelector -// -// Created by Michael Kavouras on 8/9/15. -// Copyright (c) 2015 Mike Kavouras. All rights reserved. -// - -#import "ViewController.h" - -@interface ViewController () - -@end - -@implementation ViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -@end diff --git a/README.md b/README.md index bc42baf..fef4457 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,33 @@ # Option Selector #### Summary -Create a simple app with a few different categories (dogs, cars, food, planets, etc). When you tap on a category name it should take you into another `UITableViewController` with a list of possible options. Tapping on an option will show a checkmark at the right of the cell, and remove any other checkmarks on any other cells. When you navigate back to the initial `UITableViewController` you should see the option that you chose next in the corresponding cell. That is all. -You may pick any categories that you want. +This is an application that allows you to select your own video game from a genre you've selected on the previous screen. When you select a catergory or genre of games, for example, horror, adventure, or shooter, then it will take you to another screen. This new screen is a UITableViewController with a list of different games from that selected genere. Once a cell is tapped, a checkmark will appear on the right side of the cell, and tapping on another cell will remove the previous checkmark and show the new checkmark on the selected cell. Navigating back on the 'root' view controller that list the categories will now show the game corresponding to the cell. + +Example: ![image](https://github.com/accesscode-2-2/unit-1/blob/master/lessons/week-4/images/options.gif?raw=true) -### Organization -This is a suggestion for how to organize your data. -1. Each category is represented by a class. Each category class has 3 properties: name (NSString*), options (NSArray*), selection (NSString*) -2. In your root `UITableViewController`, add a `property` that is an `NSArray` that can hold all of your category objects. -3. In `prepareForSegue`, pass the category object to the other `UITableViewController` +The MIT License + +Copyright (c) 2010-2015 Google, Inc. http://angularjs.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. -### Process - TBD +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE.