diff --git a/OptionSelector.xcodeproj/project.pbxproj b/OptionSelector.xcodeproj/project.pbxproj index 1788504..b7a7a18 100644 --- a/OptionSelector.xcodeproj/project.pbxproj +++ b/OptionSelector.xcodeproj/project.pbxproj @@ -7,9 +7,11 @@ objects = { /* Begin PBXBuildFile section */ + 224523381B7ADB8A003B0FD8 /* OSCategoriesTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 224523371B7ADB8A003B0FD8 /* OSCategoriesTableViewController.m */; }; + 2245233B1B7ADBEC003B0FD8 /* OSStuffTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2245233A1B7ADBEC003B0FD8 /* OSStuffTableViewController.m */; }; + 224523411B7ADF22003B0FD8 /* CQCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = 224523401B7ADF22003B0FD8 /* 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 +29,17 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 224523361B7ADB8A003B0FD8 /* OSCategoriesTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSCategoriesTableViewController.h; sourceTree = ""; }; + 224523371B7ADB8A003B0FD8 /* OSCategoriesTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OSCategoriesTableViewController.m; sourceTree = ""; }; + 224523391B7ADBEC003B0FD8 /* OSStuffTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSStuffTableViewController.h; sourceTree = ""; }; + 2245233A1B7ADBEC003B0FD8 /* OSStuffTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OSStuffTableViewController.m; sourceTree = ""; }; + 2245233F1B7ADF22003B0FD8 /* CQCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CQCategory.h; sourceTree = ""; }; + 224523401B7ADF22003B0FD8 /* 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 +89,12 @@ children = ( 8DECE7931B78082B0064D760 /* AppDelegate.h */, 8DECE7941B78082B0064D760 /* AppDelegate.m */, - 8DECE7961B78082B0064D760 /* ViewController.h */, - 8DECE7971B78082B0064D760 /* ViewController.m */, + 2245233F1B7ADF22003B0FD8 /* CQCategory.h */, + 224523401B7ADF22003B0FD8 /* CQCategory.m */, + 224523361B7ADB8A003B0FD8 /* OSCategoriesTableViewController.h */, + 224523371B7ADB8A003B0FD8 /* OSCategoriesTableViewController.m */, + 224523391B7ADBEC003B0FD8 /* OSStuffTableViewController.h */, + 2245233A1B7ADBEC003B0FD8 /* OSStuffTableViewController.m */, 8DECE7991B78082B0064D760 /* Main.storyboard */, 8DECE79C1B78082B0064D760 /* Images.xcassets */, 8DECE79E1B78082B0064D760 /* LaunchScreen.xib */, @@ -219,8 +229,10 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8DECE7981B78082B0064D760 /* ViewController.m in Sources */, + 224523411B7ADF22003B0FD8 /* CQCategory.m in Sources */, + 224523381B7ADB8A003B0FD8 /* OSCategoriesTableViewController.m in Sources */, 8DECE7951B78082B0064D760 /* AppDelegate.m in Sources */, + 2245233B1B7ADBEC003B0FD8 /* OSStuffTableViewController.m in Sources */, 8DECE7921B78082B0064D760 /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -418,6 +430,7 @@ 8DECE7B11B78082B0064D760 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 8DECE7B21B78082B0064D760 /* Build configuration list for PBXNativeTarget "OptionSelectorTests" */ = { isa = XCConfigurationList; @@ -426,6 +439,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..b41eaf8 100644 --- a/OptionSelector/Base.lproj/Main.storyboard +++ b/OptionSelector/Base.lproj/Main.storyboard @@ -1,25 +1,102 @@ - + - + - - + + - - - - - - + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OptionSelector/CQCategory.h b/OptionSelector/CQCategory.h new file mode 100644 index 0000000..fd22c9f --- /dev/null +++ b/OptionSelector/CQCategory.h @@ -0,0 +1,17 @@ +// +// Category.h +// OptionSelector +// +// Created by Daniel Distant 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..79179c3 --- /dev/null +++ b/OptionSelector/CQCategory.m @@ -0,0 +1,13 @@ +// +// Category.m +// OptionSelector +// +// Created by Daniel Distant on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "CQCategory.h" + +@implementation CQCategory + +@end diff --git a/OptionSelector/OSCategoriesTableViewController.h b/OptionSelector/OSCategoriesTableViewController.h new file mode 100644 index 0000000..1438bdb --- /dev/null +++ b/OptionSelector/OSCategoriesTableViewController.h @@ -0,0 +1,13 @@ +// +// OSCategoriesTableViewController.h +// OptionSelector +// +// Created by Daniel Distant on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface OSCategoriesTableViewController : UITableViewController + +@end diff --git a/OptionSelector/OSCategoriesTableViewController.m b/OptionSelector/OSCategoriesTableViewController.m new file mode 100644 index 0000000..9fcf80d --- /dev/null +++ b/OptionSelector/OSCategoriesTableViewController.m @@ -0,0 +1,125 @@ +// +// OSCategoriesTableViewController.m +// OptionSelector +// +// Created by Daniel Distant on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "OSCategoriesTableViewController.h" +#import "CQCategory.h" +#import "OSStuffTableViewController.h" + +@interface OSCategoriesTableViewController () + +@property (nonatomic) NSArray *CQCategories; + + + +@end + +@implementation OSCategoriesTableViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + CQCategory *dogs = [[CQCategory alloc] init]; + CQCategory *cats = [[CQCategory alloc] init]; + CQCategory *birds = [[CQCategory alloc] init]; + CQCategory *mikes = [[CQCategory alloc] init]; + + self.CQCategories = [[NSArray alloc] init]; + + self.CQCategories = @[ + dogs, + cats, + birds, + mikes + ]; + + dogs.name = @"dogs"; + cats.name = @"cats"; + birds.name = @"birds"; + mikes.name = @"mikes"; + + + dogs.options = @[ + @"siberian husky", + @"pit bull", + @"staffordshire terrier", + @"shiba inu" + ]; + + //any dog under 15 lbs is a cat + + cats.options = @[ + @"garfield", + @"chihuahua", + @"poodle", + @"the weird hairless kind" + ]; + + birds.options = @[ + @"peregrine falcon", + @"osprey", + @"golden eagle", + @"red-tailed hawk named Tobias" + ]; + + mikes.options = @[ + @"default Mike with sidekick Max", + @"evil French twin Mikael", + @"git legend Mike with dual-wield Macbooks", + @"Mike with weaponized flip-flops", + @"rare holographic non-mustache Mike" + ]; + + +} + +-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + + OSStuffTableViewController *stuffTableViewController = [[OSStuffTableViewController alloc]init]; + stuffTableViewController = segue.destinationViewController; + NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; + stuffTableViewController.category = [self.CQCategories objectAtIndex:indexPath.row]; + + if (([stuffTableViewController.tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark)) { + + stuffTableViewController.category.selection = [stuffTableViewController.category.options objectAtIndex:indexPath.row]; + + [self.tableView cellForRowAtIndexPath:indexPath].detailTextLabel.text = stuffTableViewController.category.selection; + } + +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + + return self.CQCategories.count; +} + + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"categoriesCell" forIndexPath:indexPath]; + + CQCategory *cellCategory = [self.CQCategories objectAtIndex:indexPath.row]; + + cell.textLabel.text = cellCategory.name; + + return cell; +} + +-(void)viewDidAppear:(BOOL)animated { + + [self.tableView reloadData]; +} + +@end diff --git a/OptionSelector/OSStuffTableViewController.h b/OptionSelector/OSStuffTableViewController.h new file mode 100644 index 0000000..644c954 --- /dev/null +++ b/OptionSelector/OSStuffTableViewController.h @@ -0,0 +1,16 @@ +// +// OSStuffTableViewController.h +// OptionSelector +// +// Created by Daniel Distant on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import +#import "CQCategory.h" + +@interface OSStuffTableViewController : UITableViewController + +@property (nonatomic) CQCategory *category; + +@end diff --git a/OptionSelector/OSStuffTableViewController.m b/OptionSelector/OSStuffTableViewController.m new file mode 100644 index 0000000..e42f7de --- /dev/null +++ b/OptionSelector/OSStuffTableViewController.m @@ -0,0 +1,59 @@ +// +// OSStuffTableViewController.m +// OptionSelector +// +// Created by Daniel Distant on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "OSStuffTableViewController.h" + +@interface OSStuffTableViewController () + +@end + +@implementation OSStuffTableViewController + +- (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.category.options.count; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"stuffCell" forIndexPath:indexPath]; + + cell.textLabel.text = [self.category.options objectAtIndex:indexPath.row]; + + return cell; +} + +-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + + [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark; + + +} + +-(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