From 21aa88c7cc4deb3e33df0ad03b38084590b338e1 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 11 Aug 2015 14:33:11 -0400 Subject: [PATCH 01/10] set up inital outline --- OptionSelector/Base.lproj/Main.storyboard | 85 +++++++++++++++++++---- 1 file changed, 70 insertions(+), 15 deletions(-) diff --git a/OptionSelector/Base.lproj/Main.storyboard b/OptionSelector/Base.lproj/Main.storyboard index d912f9d..fb8c490 100644 --- a/OptionSelector/Base.lproj/Main.storyboard +++ b/OptionSelector/Base.lproj/Main.storyboard @@ -1,25 +1,80 @@ - + - + - - + + - - - - - - + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 824c898b19f29e283dce99459b37dffe0c8fd77a Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 11 Aug 2015 15:44:12 -0400 Subject: [PATCH 02/10] further initial setup --- OptionSelector.xcodeproj/project.pbxproj | 20 ++-- OptionSelector/Base.lproj/Main.storyboard | 27 +++-- .../CategoryOptionsTableViewController.h | 13 +++ .../CategoryOptionsTableViewController.m | 102 ++++++++++++++++++ OptionSelector/CategoryTableViewController.h | 13 +++ OptionSelector/CategoryTableViewController.m | 98 +++++++++++++++++ 6 files changed, 253 insertions(+), 20 deletions(-) create mode 100644 OptionSelector/CategoryOptionsTableViewController.h create mode 100644 OptionSelector/CategoryOptionsTableViewController.m create mode 100644 OptionSelector/CategoryTableViewController.h create mode 100644 OptionSelector/CategoryTableViewController.m diff --git a/OptionSelector.xcodeproj/project.pbxproj b/OptionSelector.xcodeproj/project.pbxproj index 1788504..c941050 100644 --- a/OptionSelector.xcodeproj/project.pbxproj +++ b/OptionSelector.xcodeproj/project.pbxproj @@ -7,9 +7,10 @@ objects = { /* Begin PBXBuildFile section */ + 42F300BC1B7A782500FD7DA6 /* CategoryTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42F300BB1B7A782500FD7DA6 /* CategoryTableViewController.m */; }; + 42F300BF1B7A78A900FD7DA6 /* CategoryOptionsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42F300BE1B7A78A900FD7DA6 /* CategoryOptionsTableViewController.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 +28,15 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 42F300BA1B7A782500FD7DA6 /* CategoryTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CategoryTableViewController.h; sourceTree = ""; }; + 42F300BB1B7A782500FD7DA6 /* CategoryTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CategoryTableViewController.m; sourceTree = ""; }; + 42F300BD1B7A78A900FD7DA6 /* CategoryOptionsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CategoryOptionsTableViewController.h; sourceTree = ""; }; + 42F300BE1B7A78A900FD7DA6 /* CategoryOptionsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CategoryOptionsTableViewController.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 +86,10 @@ children = ( 8DECE7931B78082B0064D760 /* AppDelegate.h */, 8DECE7941B78082B0064D760 /* AppDelegate.m */, - 8DECE7961B78082B0064D760 /* ViewController.h */, - 8DECE7971B78082B0064D760 /* ViewController.m */, + 42F300BA1B7A782500FD7DA6 /* CategoryTableViewController.h */, + 42F300BB1B7A782500FD7DA6 /* CategoryTableViewController.m */, + 42F300BD1B7A78A900FD7DA6 /* CategoryOptionsTableViewController.h */, + 42F300BE1B7A78A900FD7DA6 /* CategoryOptionsTableViewController.m */, 8DECE7991B78082B0064D760 /* Main.storyboard */, 8DECE79C1B78082B0064D760 /* Images.xcassets */, 8DECE79E1B78082B0064D760 /* LaunchScreen.xib */, @@ -219,8 +224,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8DECE7981B78082B0064D760 /* ViewController.m in Sources */, + 42F300BF1B7A78A900FD7DA6 /* CategoryOptionsTableViewController.m in Sources */, 8DECE7951B78082B0064D760 /* AppDelegate.m in Sources */, + 42F300BC1B7A782500FD7DA6 /* CategoryTableViewController.m in Sources */, 8DECE7921B78082B0064D760 /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -418,6 +424,7 @@ 8DECE7B11B78082B0064D760 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 8DECE7B21B78082B0064D760 /* Build configuration list for PBXNativeTarget "OptionSelectorTests" */ = { isa = XCConfigurationList; @@ -426,6 +433,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 fb8c490..a482913 100644 --- a/OptionSelector/Base.lproj/Main.storyboard +++ b/OptionSelector/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -7,19 +7,19 @@ - + - + - + @@ -28,33 +28,32 @@ + + - + - - + + - + - + - - - - + @@ -69,7 +68,7 @@ - + diff --git a/OptionSelector/CategoryOptionsTableViewController.h b/OptionSelector/CategoryOptionsTableViewController.h new file mode 100644 index 0000000..5189284 --- /dev/null +++ b/OptionSelector/CategoryOptionsTableViewController.h @@ -0,0 +1,13 @@ +// +// CategoryOptionsTableViewController.h +// OptionSelector +// +// Created by Charles Kang on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface CategoryOptionsTableViewController : UITableViewController + +@end diff --git a/OptionSelector/CategoryOptionsTableViewController.m b/OptionSelector/CategoryOptionsTableViewController.m new file mode 100644 index 0000000..85f4fe3 --- /dev/null +++ b/OptionSelector/CategoryOptionsTableViewController.m @@ -0,0 +1,102 @@ +// +// CategoryOptionsTableViewController.m +// OptionSelector +// +// Created by Charles Kang on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "CategoryOptionsTableViewController.h" + +@interface CategoryOptionsTableViewController () + +@property (nonatomic) NSArray *threeOptions; + +@end + +@implementation CategoryOptionsTableViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + self.title = @"Food, Countries, and Shoes"; + + + NSArray *food = @[@"Mango", @"Pasta", @"Pizza", @"Ravioli", @"Krabby Patty"]; + NSArray *countries = @[@"Japan", @"Korea", @"France", @"Spain", @"Brazil"]; + NSArray *shoes = @[@"Nike", @"Adidas", @"Reebok", @"Converse", @"Saucony", @"New Balance"]; + + self.threeOptions = @[food,countries,shoes]; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return self.threeOptions.count; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return ((NSArray *)self.threeOptions[section]).count; + +} + + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"categoryIdentifier" forIndexPath:indexPath]; + + NSArray *categoryArray = self.threeOptions[indexPath.section]; + cell.textLabel.text = (NSString *)categoryArray[indexPath.row]; + + return cell; +} + + +/* + // Override to support conditional editing of the table view. + - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the specified item to be editable. + return YES; + } + */ + +/* + // Override to support editing the table view. + - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + if (editingStyle == UITableViewCellEditingStyleDelete) { + // Delete the row from the data source + [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; + } else if (editingStyle == UITableViewCellEditingStyleInsert) { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view + } + } + */ + +/* + // Override to support rearranging the table view. + - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { + } + */ + +/* + // Override to support conditional rearranging of the table view. + - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the item to be re-orderable. + return YES; + } + */ + +/* + #pragma mark - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. + } + */ + +@end diff --git a/OptionSelector/CategoryTableViewController.h b/OptionSelector/CategoryTableViewController.h new file mode 100644 index 0000000..db58121 --- /dev/null +++ b/OptionSelector/CategoryTableViewController.h @@ -0,0 +1,13 @@ +// +// CategoryTableViewController.h +// OptionSelector +// +// Created by Charles Kang on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface CategoryTableViewController : UITableViewController + +@end diff --git a/OptionSelector/CategoryTableViewController.m b/OptionSelector/CategoryTableViewController.m new file mode 100644 index 0000000..c858c2c --- /dev/null +++ b/OptionSelector/CategoryTableViewController.m @@ -0,0 +1,98 @@ +// +// CategoryTableViewController.m +// OptionSelector +// +// Created by Charles Kang on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "CategoryTableViewController.h" +#import "CategoryOptionsTableViewController.h" + +@interface CategoryTableViewController () + +@end + +@implementation CategoryTableViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + self.navigationController.navigationBar.backItem.title = @"Custom text"; + + // Uncomment the following line to preserve selection between presentations. + // self.clearsSelectionOnViewWillAppear = NO; + + // Uncomment the following line to display an Edit button in the navigation bar for this view controller. + // self.navigationItem.rightBarButtonItem = self.editButtonItem; +} + + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { +#warning Potentially incomplete method implementation. + // Return the number of sections. + return 0; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { +#warning Incomplete method implementation. + // Return the number of rows in the section. + return 0; +} + +/* +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath]; + + // Configure the cell... + + return cell; +} +*/ + +/* +// Override to support conditional editing of the table view. +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the specified item to be editable. + return YES; +} +*/ + +/* +// Override to support editing the table view. +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + if (editingStyle == UITableViewCellEditingStyleDelete) { + // Delete the row from the data source + [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; + } else if (editingStyle == UITableViewCellEditingStyleInsert) { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view + } +} +*/ + +/* +// Override to support rearranging the table view. +- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { +} +*/ + +/* +// Override to support conditional rearranging of the table view. +- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the item to be re-orderable. + return YES; +} +*/ + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end From 2b59445607eaaf49cd473ed40f1d4cf36547771e Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 11 Aug 2015 23:00:51 -0400 Subject: [PATCH 03/10] restarted project, added better organization --- OptionSelector.xcodeproj/project.pbxproj | 48 ++++++--- OptionSelector/Base.lproj/Main.storyboard | 101 +++++++++-------- OptionSelector/Categories.h | 13 +++ OptionSelector/Categories.m | 13 +++ OptionSelector/CategoryMain.h | 13 +++ OptionSelector/CategoryMain.m | 13 +++ .../CategoryOptionsTableViewController.m | 102 ------------------ OptionSelector/CategorySetup.h | 13 +++ OptionSelector/CategorySetup.m | 13 +++ OptionSelector/CategoryTableViewController.m | 6 +- OptionSelector/Countries.h | 13 +++ OptionSelector/Countries.m | 13 +++ OptionSelector/Food.h | 13 +++ OptionSelector/Food.m | 13 +++ ...h => OptionSelectionTableViewController.h} | 4 +- .../OptionSelectionTableViewController.m | 100 +++++++++++++++++ OptionSelector/Shoes.h | 13 +++ OptionSelector/Shoes.m | 13 +++ OptionSelector/ThreeCategoryOptions.h | 13 +++ OptionSelector/ThreeCategoryOptions.m | 13 +++ 20 files changed, 382 insertions(+), 161 deletions(-) create mode 100644 OptionSelector/Categories.h create mode 100644 OptionSelector/Categories.m create mode 100644 OptionSelector/CategoryMain.h create mode 100644 OptionSelector/CategoryMain.m delete mode 100644 OptionSelector/CategoryOptionsTableViewController.m create mode 100644 OptionSelector/CategorySetup.h create mode 100644 OptionSelector/CategorySetup.m create mode 100644 OptionSelector/Countries.h create mode 100644 OptionSelector/Countries.m create mode 100644 OptionSelector/Food.h create mode 100644 OptionSelector/Food.m rename OptionSelector/{CategoryOptionsTableViewController.h => OptionSelectionTableViewController.h} (61%) create mode 100644 OptionSelector/OptionSelectionTableViewController.m create mode 100644 OptionSelector/Shoes.h create mode 100644 OptionSelector/Shoes.m create mode 100644 OptionSelector/ThreeCategoryOptions.h create mode 100644 OptionSelector/ThreeCategoryOptions.m diff --git a/OptionSelector.xcodeproj/project.pbxproj b/OptionSelector.xcodeproj/project.pbxproj index c941050..7c9b76a 100644 --- a/OptionSelector.xcodeproj/project.pbxproj +++ b/OptionSelector.xcodeproj/project.pbxproj @@ -7,8 +7,12 @@ objects = { /* Begin PBXBuildFile section */ - 42F300BC1B7A782500FD7DA6 /* CategoryTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42F300BB1B7A782500FD7DA6 /* CategoryTableViewController.m */; }; - 42F300BF1B7A78A900FD7DA6 /* CategoryOptionsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 42F300BE1B7A78A900FD7DA6 /* CategoryOptionsTableViewController.m */; }; + 4250F2C11B7AEB92009CBF9E /* Categories.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2C01B7AEB92009CBF9E /* Categories.m */; }; + 4250F2CD1B7AEC8B009CBF9E /* CategorySetup.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2CC1B7AEC8B009CBF9E /* CategorySetup.m */; }; + 4250F2D01B7AED11009CBF9E /* CategoryMain.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2CF1B7AED11009CBF9E /* CategoryMain.m */; }; + 4250F2D31B7AED4F009CBF9E /* CategoryTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2D21B7AED4F009CBF9E /* CategoryTableViewController.m */; }; + 4250F2D61B7AED9C009CBF9E /* ThreeCategoryOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2D51B7AED9C009CBF9E /* ThreeCategoryOptions.m */; }; + 4250F2D91B7AEE1D009CBF9E /* OptionSelectionTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2D81B7AEE1D009CBF9E /* OptionSelectionTableViewController.m */; }; 8DECE7921B78082B0064D760 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DECE7911B78082B0064D760 /* main.m */; }; 8DECE7951B78082B0064D760 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DECE7941B78082B0064D760 /* AppDelegate.m */; }; 8DECE79B1B78082B0064D760 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8DECE7991B78082B0064D760 /* Main.storyboard */; }; @@ -28,10 +32,18 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 42F300BA1B7A782500FD7DA6 /* CategoryTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CategoryTableViewController.h; sourceTree = ""; }; - 42F300BB1B7A782500FD7DA6 /* CategoryTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CategoryTableViewController.m; sourceTree = ""; }; - 42F300BD1B7A78A900FD7DA6 /* CategoryOptionsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CategoryOptionsTableViewController.h; sourceTree = ""; }; - 42F300BE1B7A78A900FD7DA6 /* CategoryOptionsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CategoryOptionsTableViewController.m; sourceTree = ""; }; + 4250F2BF1B7AEB92009CBF9E /* Categories.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Categories.h; sourceTree = ""; }; + 4250F2C01B7AEB92009CBF9E /* Categories.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Categories.m; sourceTree = ""; }; + 4250F2CB1B7AEC8B009CBF9E /* CategorySetup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CategorySetup.h; sourceTree = ""; }; + 4250F2CC1B7AEC8B009CBF9E /* CategorySetup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CategorySetup.m; sourceTree = ""; }; + 4250F2CE1B7AED11009CBF9E /* CategoryMain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CategoryMain.h; sourceTree = ""; }; + 4250F2CF1B7AED11009CBF9E /* CategoryMain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CategoryMain.m; sourceTree = ""; }; + 4250F2D11B7AED4F009CBF9E /* CategoryTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CategoryTableViewController.h; sourceTree = ""; }; + 4250F2D21B7AED4F009CBF9E /* CategoryTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CategoryTableViewController.m; sourceTree = ""; }; + 4250F2D41B7AED9C009CBF9E /* ThreeCategoryOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreeCategoryOptions.h; sourceTree = ""; }; + 4250F2D51B7AED9C009CBF9E /* ThreeCategoryOptions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ThreeCategoryOptions.m; sourceTree = ""; }; + 4250F2D71B7AEE1D009CBF9E /* OptionSelectionTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OptionSelectionTableViewController.h; sourceTree = ""; }; + 4250F2D81B7AEE1D009CBF9E /* OptionSelectionTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OptionSelectionTableViewController.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 = ""; }; @@ -86,10 +98,18 @@ children = ( 8DECE7931B78082B0064D760 /* AppDelegate.h */, 8DECE7941B78082B0064D760 /* AppDelegate.m */, - 42F300BA1B7A782500FD7DA6 /* CategoryTableViewController.h */, - 42F300BB1B7A782500FD7DA6 /* CategoryTableViewController.m */, - 42F300BD1B7A78A900FD7DA6 /* CategoryOptionsTableViewController.h */, - 42F300BE1B7A78A900FD7DA6 /* CategoryOptionsTableViewController.m */, + 4250F2BF1B7AEB92009CBF9E /* Categories.h */, + 4250F2C01B7AEB92009CBF9E /* Categories.m */, + 4250F2D41B7AED9C009CBF9E /* ThreeCategoryOptions.h */, + 4250F2D51B7AED9C009CBF9E /* ThreeCategoryOptions.m */, + 4250F2CB1B7AEC8B009CBF9E /* CategorySetup.h */, + 4250F2CC1B7AEC8B009CBF9E /* CategorySetup.m */, + 4250F2CE1B7AED11009CBF9E /* CategoryMain.h */, + 4250F2CF1B7AED11009CBF9E /* CategoryMain.m */, + 4250F2D11B7AED4F009CBF9E /* CategoryTableViewController.h */, + 4250F2D21B7AED4F009CBF9E /* CategoryTableViewController.m */, + 4250F2D71B7AEE1D009CBF9E /* OptionSelectionTableViewController.h */, + 4250F2D81B7AEE1D009CBF9E /* OptionSelectionTableViewController.m */, 8DECE7991B78082B0064D760 /* Main.storyboard */, 8DECE79C1B78082B0064D760 /* Images.xcassets */, 8DECE79E1B78082B0064D760 /* LaunchScreen.xib */, @@ -224,9 +244,13 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 42F300BF1B7A78A900FD7DA6 /* CategoryOptionsTableViewController.m in Sources */, 8DECE7951B78082B0064D760 /* AppDelegate.m in Sources */, - 42F300BC1B7A782500FD7DA6 /* CategoryTableViewController.m in Sources */, + 4250F2D31B7AED4F009CBF9E /* CategoryTableViewController.m in Sources */, + 4250F2D01B7AED11009CBF9E /* CategoryMain.m in Sources */, + 4250F2CD1B7AEC8B009CBF9E /* CategorySetup.m in Sources */, + 4250F2D61B7AED9C009CBF9E /* ThreeCategoryOptions.m in Sources */, + 4250F2D91B7AEE1D009CBF9E /* OptionSelectionTableViewController.m in Sources */, + 4250F2C11B7AEB92009CBF9E /* Categories.m in Sources */, 8DECE7921B78082B0064D760 /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/OptionSelector/Base.lproj/Main.storyboard b/OptionSelector/Base.lproj/Main.storyboard index a482913..13d44c9 100644 --- a/OptionSelector/Base.lproj/Main.storyboard +++ b/OptionSelector/Base.lproj/Main.storyboard @@ -1,79 +1,94 @@ - + - - + + - - + + + + + + + + + + + + + + + + + + - + - + + + + + - - - - - + + - - - + + + + - + - + - - + + - - + + - + - + - + + + + + - - - - - - - - - - - - - - - - - - + - + diff --git a/OptionSelector/Categories.h b/OptionSelector/Categories.h new file mode 100644 index 0000000..725afe5 --- /dev/null +++ b/OptionSelector/Categories.h @@ -0,0 +1,13 @@ +// +// Categories.h +// OptionSelector +// +// Created by Charles Kang on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface Categories : NSObject + +@end diff --git a/OptionSelector/Categories.m b/OptionSelector/Categories.m new file mode 100644 index 0000000..e999518 --- /dev/null +++ b/OptionSelector/Categories.m @@ -0,0 +1,13 @@ +// +// Categories.m +// OptionSelector +// +// Created by Charles Kang on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "Categories.h" + +@implementation Categories + +@end diff --git a/OptionSelector/CategoryMain.h b/OptionSelector/CategoryMain.h new file mode 100644 index 0000000..b5748fd --- /dev/null +++ b/OptionSelector/CategoryMain.h @@ -0,0 +1,13 @@ +// +// CategoryMain.h +// OptionSelector +// +// Created by Charles Kang on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "Categories.h" + +@interface CategoryMain : Categories + +@end diff --git a/OptionSelector/CategoryMain.m b/OptionSelector/CategoryMain.m new file mode 100644 index 0000000..91802bd --- /dev/null +++ b/OptionSelector/CategoryMain.m @@ -0,0 +1,13 @@ +// +// CategoryMain.m +// OptionSelector +// +// Created by Charles Kang on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "CategoryMain.h" + +@implementation CategoryMain + +@end diff --git a/OptionSelector/CategoryOptionsTableViewController.m b/OptionSelector/CategoryOptionsTableViewController.m deleted file mode 100644 index 85f4fe3..0000000 --- a/OptionSelector/CategoryOptionsTableViewController.m +++ /dev/null @@ -1,102 +0,0 @@ -// -// CategoryOptionsTableViewController.m -// OptionSelector -// -// Created by Charles Kang on 8/11/15. -// Copyright (c) 2015 Mike Kavouras. All rights reserved. -// - -#import "CategoryOptionsTableViewController.h" - -@interface CategoryOptionsTableViewController () - -@property (nonatomic) NSArray *threeOptions; - -@end - -@implementation CategoryOptionsTableViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - self.title = @"Food, Countries, and Shoes"; - - - NSArray *food = @[@"Mango", @"Pasta", @"Pizza", @"Ravioli", @"Krabby Patty"]; - NSArray *countries = @[@"Japan", @"Korea", @"France", @"Spain", @"Brazil"]; - NSArray *shoes = @[@"Nike", @"Adidas", @"Reebok", @"Converse", @"Saucony", @"New Balance"]; - - self.threeOptions = @[food,countries,shoes]; -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -#pragma mark - Table view data source - -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return self.threeOptions.count; -} - -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return ((NSArray *)self.threeOptions[section]).count; - -} - - -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"categoryIdentifier" forIndexPath:indexPath]; - - NSArray *categoryArray = self.threeOptions[indexPath.section]; - cell.textLabel.text = (NSString *)categoryArray[indexPath.row]; - - return cell; -} - - -/* - // Override to support conditional editing of the table view. - - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { - // Return NO if you do not want the specified item to be editable. - return YES; - } - */ - -/* - // Override to support editing the table view. - - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { - if (editingStyle == UITableViewCellEditingStyleDelete) { - // Delete the row from the data source - [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; - } else if (editingStyle == UITableViewCellEditingStyleInsert) { - // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view - } - } - */ - -/* - // Override to support rearranging the table view. - - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { - } - */ - -/* - // Override to support conditional rearranging of the table view. - - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { - // Return NO if you do not want the item to be re-orderable. - return YES; - } - */ - -/* - #pragma mark - Navigation - - // In a storyboard-based application, you will often want to do a little preparation before navigation - - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - // Get the new view controller using [segue destinationViewController]. - // Pass the selected object to the new view controller. - } - */ - -@end diff --git a/OptionSelector/CategorySetup.h b/OptionSelector/CategorySetup.h new file mode 100644 index 0000000..64a5428 --- /dev/null +++ b/OptionSelector/CategorySetup.h @@ -0,0 +1,13 @@ +// +// CategorySetup.h +// OptionSelector +// +// Created by Charles Kang on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "Categories.h" + +@interface CategorySetup : Categories + +@end diff --git a/OptionSelector/CategorySetup.m b/OptionSelector/CategorySetup.m new file mode 100644 index 0000000..d520d7f --- /dev/null +++ b/OptionSelector/CategorySetup.m @@ -0,0 +1,13 @@ +// +// CategorySetup.m +// OptionSelector +// +// Created by Charles Kang on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "CategorySetup.h" + +@implementation CategorySetup + +@end diff --git a/OptionSelector/CategoryTableViewController.m b/OptionSelector/CategoryTableViewController.m index c858c2c..6e9200f 100644 --- a/OptionSelector/CategoryTableViewController.m +++ b/OptionSelector/CategoryTableViewController.m @@ -7,7 +7,6 @@ // #import "CategoryTableViewController.h" -#import "CategoryOptionsTableViewController.h" @interface CategoryTableViewController () @@ -17,7 +16,6 @@ @implementation CategoryTableViewController - (void)viewDidLoad { [super viewDidLoad]; - self.navigationController.navigationBar.backItem.title = @"Custom text"; // Uncomment the following line to preserve selection between presentations. // self.clearsSelectionOnViewWillAppear = NO; @@ -26,6 +24,10 @@ - (void)viewDidLoad { // self.navigationItem.rightBarButtonItem = self.editButtonItem; } +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} #pragma mark - Table view data source diff --git a/OptionSelector/Countries.h b/OptionSelector/Countries.h new file mode 100644 index 0000000..ad7c664 --- /dev/null +++ b/OptionSelector/Countries.h @@ -0,0 +1,13 @@ +// +// Countries.h +// OptionSelector +// +// Created by Charles Kang on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "Categories.h" + +@interface Countries : Categories + +@end diff --git a/OptionSelector/Countries.m b/OptionSelector/Countries.m new file mode 100644 index 0000000..d7889a9 --- /dev/null +++ b/OptionSelector/Countries.m @@ -0,0 +1,13 @@ +// +// Countries.m +// OptionSelector +// +// Created by Charles Kang on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "Countries.h" + +@implementation Countries + +@end diff --git a/OptionSelector/Food.h b/OptionSelector/Food.h new file mode 100644 index 0000000..90d300b --- /dev/null +++ b/OptionSelector/Food.h @@ -0,0 +1,13 @@ +// +// Food.h +// OptionSelector +// +// Created by Charles Kang on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "Categories.h" + +@interface Food : Categories + +@end diff --git a/OptionSelector/Food.m b/OptionSelector/Food.m new file mode 100644 index 0000000..425eac8 --- /dev/null +++ b/OptionSelector/Food.m @@ -0,0 +1,13 @@ +// +// Food.m +// OptionSelector +// +// Created by Charles Kang on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "Food.h" + +@implementation Food + +@end diff --git a/OptionSelector/CategoryOptionsTableViewController.h b/OptionSelector/OptionSelectionTableViewController.h similarity index 61% rename from OptionSelector/CategoryOptionsTableViewController.h rename to OptionSelector/OptionSelectionTableViewController.h index 5189284..ce72f01 100644 --- a/OptionSelector/CategoryOptionsTableViewController.h +++ b/OptionSelector/OptionSelectionTableViewController.h @@ -1,5 +1,5 @@ // -// CategoryOptionsTableViewController.h +// OptionSelectionTableViewController.h // OptionSelector // // Created by Charles Kang on 8/11/15. @@ -8,6 +8,6 @@ #import -@interface CategoryOptionsTableViewController : UITableViewController +@interface OptionSelectionTableViewController : UITableViewController @end diff --git a/OptionSelector/OptionSelectionTableViewController.m b/OptionSelector/OptionSelectionTableViewController.m new file mode 100644 index 0000000..25ecbf5 --- /dev/null +++ b/OptionSelector/OptionSelectionTableViewController.m @@ -0,0 +1,100 @@ +// +// OptionSelectionTableViewController.m +// OptionSelector +// +// Created by Charles Kang on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "OptionSelectionTableViewController.h" + +@interface OptionSelectionTableViewController () + +@end + +@implementation OptionSelectionTableViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + // Uncomment the following line to preserve selection between presentations. + // self.clearsSelectionOnViewWillAppear = NO; + + // Uncomment the following line to display an Edit button in the navigation bar for this view controller. + // self.navigationItem.rightBarButtonItem = self.editButtonItem; +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { +#warning Potentially incomplete method implementation. + // Return the number of sections. + return 0; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { +#warning Incomplete method implementation. + // Return the number of rows in the section. + return 0; +} + +/* +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath]; + + // Configure the cell... + + return cell; +} +*/ + +/* +// Override to support conditional editing of the table view. +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the specified item to be editable. + return YES; +} +*/ + +/* +// Override to support editing the table view. +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + if (editingStyle == UITableViewCellEditingStyleDelete) { + // Delete the row from the data source + [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; + } else if (editingStyle == UITableViewCellEditingStyleInsert) { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view + } +} +*/ + +/* +// Override to support rearranging the table view. +- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { +} +*/ + +/* +// Override to support conditional rearranging of the table view. +- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the item to be re-orderable. + return YES; +} +*/ + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +@end diff --git a/OptionSelector/Shoes.h b/OptionSelector/Shoes.h new file mode 100644 index 0000000..83a2bd4 --- /dev/null +++ b/OptionSelector/Shoes.h @@ -0,0 +1,13 @@ +// +// Shoes.h +// OptionSelector +// +// Created by Charles Kang on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "Categories.h" + +@interface Shoes : Categories + +@end diff --git a/OptionSelector/Shoes.m b/OptionSelector/Shoes.m new file mode 100644 index 0000000..c38e5c2 --- /dev/null +++ b/OptionSelector/Shoes.m @@ -0,0 +1,13 @@ +// +// Shoes.m +// OptionSelector +// +// Created by Charles Kang on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "Shoes.h" + +@implementation Shoes + +@end diff --git a/OptionSelector/ThreeCategoryOptions.h b/OptionSelector/ThreeCategoryOptions.h new file mode 100644 index 0000000..e56e253 --- /dev/null +++ b/OptionSelector/ThreeCategoryOptions.h @@ -0,0 +1,13 @@ +// +// ThreeCategoryOptions.h +// OptionSelector +// +// Created by Charles Kang on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "Categories.h" + +@interface ThreeCategoryOptions : Categories + +@end diff --git a/OptionSelector/ThreeCategoryOptions.m b/OptionSelector/ThreeCategoryOptions.m new file mode 100644 index 0000000..0e91a74 --- /dev/null +++ b/OptionSelector/ThreeCategoryOptions.m @@ -0,0 +1,13 @@ +// +// ThreeCategoryOptions.m +// OptionSelector +// +// Created by Charles Kang on 8/11/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "ThreeCategoryOptions.h" + +@implementation ThreeCategoryOptions + +@end From ccadaa23cc626ff9ca30ed7d726f091a43935c58 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 11 Aug 2015 23:46:02 -0400 Subject: [PATCH 04/10] more changes --- OptionSelector.xcodeproj/project.pbxproj | 30 +++++++++++++++++++----- OptionSelector/Categories.h | 3 +++ OptionSelector/ThreeCategoryOptions.h | 13 ---------- OptionSelector/ThreeCategoryOptions.m | 13 ---------- 4 files changed, 27 insertions(+), 32 deletions(-) delete mode 100644 OptionSelector/ThreeCategoryOptions.h delete mode 100644 OptionSelector/ThreeCategoryOptions.m diff --git a/OptionSelector.xcodeproj/project.pbxproj b/OptionSelector.xcodeproj/project.pbxproj index 7c9b76a..061d46c 100644 --- a/OptionSelector.xcodeproj/project.pbxproj +++ b/OptionSelector.xcodeproj/project.pbxproj @@ -11,8 +11,13 @@ 4250F2CD1B7AEC8B009CBF9E /* CategorySetup.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2CC1B7AEC8B009CBF9E /* CategorySetup.m */; }; 4250F2D01B7AED11009CBF9E /* CategoryMain.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2CF1B7AED11009CBF9E /* CategoryMain.m */; }; 4250F2D31B7AED4F009CBF9E /* CategoryTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2D21B7AED4F009CBF9E /* CategoryTableViewController.m */; }; - 4250F2D61B7AED9C009CBF9E /* ThreeCategoryOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2D51B7AED9C009CBF9E /* ThreeCategoryOptions.m */; }; 4250F2D91B7AEE1D009CBF9E /* OptionSelectionTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2D81B7AEE1D009CBF9E /* OptionSelectionTableViewController.m */; }; + 4250F2E01B7AEF78009CBF9E /* Countries.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2DB1B7AEF78009CBF9E /* Countries.m */; }; + 4250F2E11B7AEF78009CBF9E /* Countries.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2DB1B7AEF78009CBF9E /* Countries.m */; }; + 4250F2E21B7AEF78009CBF9E /* Food.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2DD1B7AEF78009CBF9E /* Food.m */; }; + 4250F2E31B7AEF78009CBF9E /* Food.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2DD1B7AEF78009CBF9E /* Food.m */; }; + 4250F2E41B7AEF78009CBF9E /* Shoes.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2DF1B7AEF78009CBF9E /* Shoes.m */; }; + 4250F2E51B7AEF78009CBF9E /* Shoes.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2DF1B7AEF78009CBF9E /* Shoes.m */; }; 8DECE7921B78082B0064D760 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DECE7911B78082B0064D760 /* main.m */; }; 8DECE7951B78082B0064D760 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DECE7941B78082B0064D760 /* AppDelegate.m */; }; 8DECE79B1B78082B0064D760 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8DECE7991B78082B0064D760 /* Main.storyboard */; }; @@ -40,10 +45,14 @@ 4250F2CF1B7AED11009CBF9E /* CategoryMain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CategoryMain.m; sourceTree = ""; }; 4250F2D11B7AED4F009CBF9E /* CategoryTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CategoryTableViewController.h; sourceTree = ""; }; 4250F2D21B7AED4F009CBF9E /* CategoryTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CategoryTableViewController.m; sourceTree = ""; }; - 4250F2D41B7AED9C009CBF9E /* ThreeCategoryOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreeCategoryOptions.h; sourceTree = ""; }; - 4250F2D51B7AED9C009CBF9E /* ThreeCategoryOptions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ThreeCategoryOptions.m; sourceTree = ""; }; 4250F2D71B7AEE1D009CBF9E /* OptionSelectionTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OptionSelectionTableViewController.h; sourceTree = ""; }; 4250F2D81B7AEE1D009CBF9E /* OptionSelectionTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OptionSelectionTableViewController.m; sourceTree = ""; }; + 4250F2DA1B7AEF78009CBF9E /* Countries.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Countries.h; sourceTree = ""; }; + 4250F2DB1B7AEF78009CBF9E /* Countries.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Countries.m; sourceTree = ""; }; + 4250F2DC1B7AEF78009CBF9E /* Food.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Food.h; sourceTree = ""; }; + 4250F2DD1B7AEF78009CBF9E /* Food.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Food.m; sourceTree = ""; }; + 4250F2DE1B7AEF78009CBF9E /* Shoes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Shoes.h; sourceTree = ""; }; + 4250F2DF1B7AEF78009CBF9E /* Shoes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Shoes.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 = ""; }; @@ -100,8 +109,12 @@ 8DECE7941B78082B0064D760 /* AppDelegate.m */, 4250F2BF1B7AEB92009CBF9E /* Categories.h */, 4250F2C01B7AEB92009CBF9E /* Categories.m */, - 4250F2D41B7AED9C009CBF9E /* ThreeCategoryOptions.h */, - 4250F2D51B7AED9C009CBF9E /* ThreeCategoryOptions.m */, + 4250F2DA1B7AEF78009CBF9E /* Countries.h */, + 4250F2DB1B7AEF78009CBF9E /* Countries.m */, + 4250F2DC1B7AEF78009CBF9E /* Food.h */, + 4250F2DD1B7AEF78009CBF9E /* Food.m */, + 4250F2DE1B7AEF78009CBF9E /* Shoes.h */, + 4250F2DF1B7AEF78009CBF9E /* Shoes.m */, 4250F2CB1B7AEC8B009CBF9E /* CategorySetup.h */, 4250F2CC1B7AEC8B009CBF9E /* CategorySetup.m */, 4250F2CE1B7AED11009CBF9E /* CategoryMain.h */, @@ -244,11 +257,13 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 4250F2E41B7AEF78009CBF9E /* Shoes.m in Sources */, + 4250F2E21B7AEF78009CBF9E /* Food.m in Sources */, 8DECE7951B78082B0064D760 /* AppDelegate.m in Sources */, 4250F2D31B7AED4F009CBF9E /* CategoryTableViewController.m in Sources */, + 4250F2E01B7AEF78009CBF9E /* Countries.m in Sources */, 4250F2D01B7AED11009CBF9E /* CategoryMain.m in Sources */, 4250F2CD1B7AEC8B009CBF9E /* CategorySetup.m in Sources */, - 4250F2D61B7AED9C009CBF9E /* ThreeCategoryOptions.m in Sources */, 4250F2D91B7AEE1D009CBF9E /* OptionSelectionTableViewController.m in Sources */, 4250F2C11B7AEB92009CBF9E /* Categories.m in Sources */, 8DECE7921B78082B0064D760 /* main.m in Sources */, @@ -259,6 +274,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 4250F2E51B7AEF78009CBF9E /* Shoes.m in Sources */, + 4250F2E31B7AEF78009CBF9E /* Food.m in Sources */, + 4250F2E11B7AEF78009CBF9E /* Countries.m in Sources */, 8DECE7AC1B78082B0064D760 /* OptionSelectorTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/OptionSelector/Categories.h b/OptionSelector/Categories.h index 725afe5..5baa744 100644 --- a/OptionSelector/Categories.h +++ b/OptionSelector/Categories.h @@ -10,4 +10,7 @@ @interface Categories : NSObject +@property (nonatomic) NSString *name; +@property (nonatomic) NSArray *choice; +@property (nonatomic) NSString *selection; @end diff --git a/OptionSelector/ThreeCategoryOptions.h b/OptionSelector/ThreeCategoryOptions.h deleted file mode 100644 index e56e253..0000000 --- a/OptionSelector/ThreeCategoryOptions.h +++ /dev/null @@ -1,13 +0,0 @@ -// -// ThreeCategoryOptions.h -// OptionSelector -// -// Created by Charles Kang on 8/11/15. -// Copyright (c) 2015 Mike Kavouras. All rights reserved. -// - -#import "Categories.h" - -@interface ThreeCategoryOptions : Categories - -@end diff --git a/OptionSelector/ThreeCategoryOptions.m b/OptionSelector/ThreeCategoryOptions.m deleted file mode 100644 index 0e91a74..0000000 --- a/OptionSelector/ThreeCategoryOptions.m +++ /dev/null @@ -1,13 +0,0 @@ -// -// ThreeCategoryOptions.m -// OptionSelector -// -// Created by Charles Kang on 8/11/15. -// Copyright (c) 2015 Mike Kavouras. All rights reserved. -// - -#import "ThreeCategoryOptions.h" - -@implementation ThreeCategoryOptions - -@end From 497eb56d3c55bc1d7cfa47feb7083df3d5805d34 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 12 Aug 2015 17:23:10 -0400 Subject: [PATCH 05/10] still need to work on storyboard, can't get instancetype method in categorymain.m to work --- OptionSelector/Base.lproj/Main.storyboard | 2 +- OptionSelector/CategoryMain.h | 3 +++ OptionSelector/CategoryMain.m | 26 +++++++++++++++++++++++ OptionSelector/CategorySetup.h | 3 +++ OptionSelector/CategorySetup.m | 26 +++++++++++++++++++++++ OptionSelector/Countries.h | 2 +- OptionSelector/Countries.m | 8 +++++++ OptionSelector/Food.m | 10 ++++++++- OptionSelector/Shoes.m | 8 +++++++ 9 files changed, 85 insertions(+), 3 deletions(-) diff --git a/OptionSelector/Base.lproj/Main.storyboard b/OptionSelector/Base.lproj/Main.storyboard index 13d44c9..ddd8cf4 100644 --- a/OptionSelector/Base.lproj/Main.storyboard +++ b/OptionSelector/Base.lproj/Main.storyboard @@ -37,7 +37,7 @@ + + + @@ -56,9 +59,6 @@ - - - @@ -88,7 +88,7 @@ - + diff --git a/OptionSelector/CategoryMain.m b/OptionSelector/CategoryMain.m index a1b8b99..9f4b3b1 100644 --- a/OptionSelector/CategoryMain.m +++ b/OptionSelector/CategoryMain.m @@ -20,7 +20,7 @@ @implementation CategoryMain + (instancetype)categoryManager { static CategoryMain *categoryManager = nil; - static dispatch_once_t onceToken; + static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ categoryManager = [[self alloc] init]; }); @@ -28,12 +28,11 @@ + (instancetype)categoryManager { return categoryManager; } -//- (instancetype)init { -// if (self = [super init]) { -// self.categoryBuild = [[CategoryMain alloc] init]; -// self.categories = [self.categoryBuild get ]; -// } -// return self; -//} +- (instancetype)init { + if (self = [super init]) { + self.categoryBuild = [[CategorySetup alloc] init]; + } + return self; +} @end diff --git a/OptionSelector/CategorySetup.h b/OptionSelector/CategorySetup.h index 9c2fbdc..35bfe72 100644 --- a/OptionSelector/CategorySetup.h +++ b/OptionSelector/CategorySetup.h @@ -11,6 +11,6 @@ @interface CategorySetup : Categories -- (NSArray *)getCategories; +- (NSArray *)fetchCategories; @end diff --git a/OptionSelector/CategorySetup.m b/OptionSelector/CategorySetup.m index 97e299d..7da4f9e 100644 --- a/OptionSelector/CategorySetup.m +++ b/OptionSelector/CategorySetup.m @@ -32,8 +32,8 @@ - (instancetype)init { return self; } -- (NSArray *)getCategories { +- (NSArray *)fetchCategories { return self.categories; } -@end +@end \ No newline at end of file diff --git a/OptionSelector/CategoryTableViewController.h b/OptionSelector/CategoryTableViewController.h index db58121..ca58beb 100644 --- a/OptionSelector/CategoryTableViewController.h +++ b/OptionSelector/CategoryTableViewController.h @@ -8,6 +8,6 @@ #import -@interface CategoryTableViewController : UITableViewController +@interface CategoryTableViewController : UITableViewController @end diff --git a/OptionSelector/CategoryTableViewController.m b/OptionSelector/CategoryTableViewController.m index 6e9200f..39083be 100644 --- a/OptionSelector/CategoryTableViewController.m +++ b/OptionSelector/CategoryTableViewController.m @@ -7,94 +7,94 @@ // #import "CategoryTableViewController.h" +#import "CategoryMain.h" +#import "OptionSelectionTableViewcontrollerDelegate.h" @interface CategoryTableViewController () +@property (nonatomic) CategoryMain *mainCategory; + @end @implementation CategoryTableViewController - (void)viewDidLoad { [super viewDidLoad]; + [self.navigationItem setTitle:@"Categories"]; - // Uncomment the following line to preserve selection between presentations. - // self.clearsSelectionOnViewWillAppear = NO; + self.mainCategory = [CategoryMain categoryManager]; - // Uncomment the following line to display an Edit button in the navigation bar for this view controller. - // self.navigationItem.rightBarButtonItem = self.editButtonItem; } -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + [self.tableView reloadData]; } #pragma mark - Table view data source - - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { -#warning Potentially incomplete method implementation. // Return the number of sections. - return 0; + return 1; } + - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { -#warning Incomplete method implementation. // Return the number of rows in the section. - return 0; + return [self.mainCategory.categories count]; } -/* + - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath]; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CategoryCellIdentifier" forIndexPath:indexPath]; - // Configure the cell... + cell.textLabel.text = [self.mainCategory.categories[indexPath.row] name]; + cell.detailTextLabel.text = [self.mainCategory.categories[indexPath.row] selection]; + cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; return cell; -} -*/ - -/* -// Override to support conditional editing of the table view. -- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { - // Return NO if you do not want the specified item to be editable. - return YES; -} -*/ - -/* -// Override to support editing the table view. -- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { - if (editingStyle == UITableViewCellEditingStyleDelete) { - // Delete the row from the data source - [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; - } else if (editingStyle == UITableViewCellEditingStyleInsert) { - // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view - } -} -*/ - -/* -// Override to support rearranging the table view. -- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { -} -*/ - -/* -// Override to support conditional rearranging of the table view. -- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { - // Return NO if you do not want the item to be re-orderable. - return YES; -} -*/ - -/* + + + + /* + // Override to support conditional editing of the table view. + - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the specified item to be editable. + return YES; + } + */ + + /* + // Override to support editing the table view. + - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + if (editingStyle == UITableViewCellEditingStyleDelete) { + // Delete the row from the data source + [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; + } else if (editingStyle == UITableViewCellEditingStyleInsert) { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view + } + } + */ + + /* + // Override to support rearranging the table view. + - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { + } + */ + + /* + // Override to support conditional rearranging of the table view. + - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the item to be re-orderable. + return YES; + } + */ + + #pragma mark - Navigation - -// In a storyboard-based application, you will often want to do a little preparation before navigation -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - // Get the new view controller using [segue destinationViewController]. - // Pass the selected object to the new view controller. -} -*/ - -@end + + - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + + } + + + @end diff --git a/OptionSelector/OptionSelectionTableViewController.h b/OptionSelector/OptionSelectionTableViewController.h index ce72f01..334bc41 100644 --- a/OptionSelector/OptionSelectionTableViewController.h +++ b/OptionSelector/OptionSelectionTableViewController.h @@ -8,6 +8,6 @@ #import -@interface OptionSelectionTableViewController : UITableViewController +@interface OptionSelectionTableViewController : UITableViewController @end diff --git a/OptionSelector/OptionSelectionTableViewControllerDelegate.h b/OptionSelector/OptionSelectionTableViewControllerDelegate.h new file mode 100644 index 0000000..23020f0 --- /dev/null +++ b/OptionSelector/OptionSelectionTableViewControllerDelegate.h @@ -0,0 +1,13 @@ +// +// OptionSelectionTableViewControllerDelegate.h +// OptionSelector +// +// Created by Charles Kang on 8/12/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface OptionSelectionTableViewControllerDelegate : NSObject + +@end diff --git a/OptionSelector/OptionSelectionTableViewControllerDelegate.m b/OptionSelector/OptionSelectionTableViewControllerDelegate.m new file mode 100644 index 0000000..73c9873 --- /dev/null +++ b/OptionSelector/OptionSelectionTableViewControllerDelegate.m @@ -0,0 +1,13 @@ +// +// OptionSelectionTableViewControllerDelegate.m +// OptionSelector +// +// Created by Charles Kang on 8/12/15. +// Copyright (c) 2015 Mike Kavouras. All rights reserved. +// + +#import "OptionSelectionTableViewControllerDelegate.h" + +@implementation OptionSelectionTableViewControllerDelegate + +@end From 37244e1b6a7bf5b1b9ce0ddfb0fed260b2d6f93d Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 12 Aug 2015 22:32:15 -0400 Subject: [PATCH 08/10] got delegate to work --- OptionSelector.xcodeproj/project.pbxproj | 4 - OptionSelector/Base.lproj/Main.storyboard | 8 +- OptionSelector/CategoryMain.m | 3 +- OptionSelector/CategorySetup.m | 3 +- OptionSelector/CategoryTableViewController.h | 3 +- OptionSelector/CategoryTableViewController.m | 15 ++-- OptionSelector/Countries.h | 1 + OptionSelector/Food.h | 1 + .../OptionSelectionTableViewController.h | 4 + .../OptionSelectionTableViewController.m | 87 +++++++++---------- ...tionSelectionTableViewControllerDelegate.h | 5 +- OptionSelector/Shoes.h | 1 + 12 files changed, 74 insertions(+), 61 deletions(-) diff --git a/OptionSelector.xcodeproj/project.pbxproj b/OptionSelector.xcodeproj/project.pbxproj index e3a14a2..5da4fc2 100644 --- a/OptionSelector.xcodeproj/project.pbxproj +++ b/OptionSelector.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 424411B51B7BFCD80055A66A /* OptionSelectionTableViewControllerDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 424411B41B7BFCD80055A66A /* OptionSelectionTableViewControllerDelegate.m */; }; 4250F2C11B7AEB92009CBF9E /* Categories.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2C01B7AEB92009CBF9E /* Categories.m */; }; 4250F2CD1B7AEC8B009CBF9E /* CategorySetup.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2CC1B7AEC8B009CBF9E /* CategorySetup.m */; }; 4250F2D01B7AED11009CBF9E /* CategoryMain.m in Sources */ = {isa = PBXBuildFile; fileRef = 4250F2CF1B7AED11009CBF9E /* CategoryMain.m */; }; @@ -39,7 +38,6 @@ /* Begin PBXFileReference section */ 424411B31B7BFCD80055A66A /* OptionSelectionTableViewControllerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OptionSelectionTableViewControllerDelegate.h; sourceTree = ""; }; - 424411B41B7BFCD80055A66A /* OptionSelectionTableViewControllerDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OptionSelectionTableViewControllerDelegate.m; sourceTree = ""; }; 4250F2BF1B7AEB92009CBF9E /* Categories.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Categories.h; sourceTree = ""; }; 4250F2C01B7AEB92009CBF9E /* Categories.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Categories.m; sourceTree = ""; }; 4250F2CB1B7AEC8B009CBF9E /* CategorySetup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CategorySetup.h; sourceTree = ""; }; @@ -127,7 +125,6 @@ 4250F2D71B7AEE1D009CBF9E /* OptionSelectionTableViewController.h */, 4250F2D81B7AEE1D009CBF9E /* OptionSelectionTableViewController.m */, 424411B31B7BFCD80055A66A /* OptionSelectionTableViewControllerDelegate.h */, - 424411B41B7BFCD80055A66A /* OptionSelectionTableViewControllerDelegate.m */, 8DECE7991B78082B0064D760 /* Main.storyboard */, 8DECE79C1B78082B0064D760 /* Images.xcassets */, 8DECE79E1B78082B0064D760 /* LaunchScreen.xib */, @@ -262,7 +259,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 424411B51B7BFCD80055A66A /* OptionSelectionTableViewControllerDelegate.m in Sources */, 4250F2E41B7AEF78009CBF9E /* Shoes.m in Sources */, 4250F2E21B7AEF78009CBF9E /* Food.m in Sources */, 8DECE7951B78082B0064D760 /* AppDelegate.m in Sources */, diff --git a/OptionSelector/Base.lproj/Main.storyboard b/OptionSelector/Base.lproj/Main.storyboard index 370a553..b5c890e 100644 --- a/OptionSelector/Base.lproj/Main.storyboard +++ b/OptionSelector/Base.lproj/Main.storyboard @@ -23,13 +23,13 @@ - + - + @@ -64,10 +64,10 @@ - + - + diff --git a/OptionSelector/CategoryMain.m b/OptionSelector/CategoryMain.m index 9f4b3b1..ac984ae 100644 --- a/OptionSelector/CategoryMain.m +++ b/OptionSelector/CategoryMain.m @@ -11,7 +11,7 @@ @interface CategoryMain () -@property (nonatomic) CategoryMain *categoryBuild; +@property (nonatomic) CategorySetup *categoryBuild; @end @@ -31,6 +31,7 @@ + (instancetype)categoryManager { - (instancetype)init { if (self = [super init]) { self.categoryBuild = [[CategorySetup alloc] init]; + self.categories = [self.categoryBuild fetchCategories]; } return self; } diff --git a/OptionSelector/CategorySetup.m b/OptionSelector/CategorySetup.m index 7da4f9e..a5cd64f 100644 --- a/OptionSelector/CategorySetup.m +++ b/OptionSelector/CategorySetup.m @@ -24,9 +24,10 @@ - (instancetype)init { Countries *countries = [[Countries alloc] init]; Food *food = [[Food alloc] init]; Shoes *shoes = [[Shoes alloc] init]; + self.categories = @[countries, food, shoes]; for (Categories *threeCategories in self.categories) { - threeCategories.selection = @""; + threeCategories.selection = @" "; } } return self; diff --git a/OptionSelector/CategoryTableViewController.h b/OptionSelector/CategoryTableViewController.h index ca58beb..e25d703 100644 --- a/OptionSelector/CategoryTableViewController.h +++ b/OptionSelector/CategoryTableViewController.h @@ -7,7 +7,8 @@ // #import +#import "OptionSelectionTableViewController.h" -@interface CategoryTableViewController : UITableViewController +@interface CategoryTableViewController : UITableViewController @end diff --git a/OptionSelector/CategoryTableViewController.m b/OptionSelector/CategoryTableViewController.m index 39083be..bcd4a72 100644 --- a/OptionSelector/CategoryTableViewController.m +++ b/OptionSelector/CategoryTableViewController.m @@ -52,8 +52,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; return cell; - - +} + /* // Override to support conditional editing of the table view. @@ -91,10 +91,15 @@ - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *) #pragma mark - Navigation - - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; + + OptionSelectionTableViewController *optionSelectors = [segue destinationViewController]; + optionSelectors.categoryIndex = indexPath.row; + optionSelectors.delegate = (id) self; } - - + + + @end diff --git a/OptionSelector/Countries.h b/OptionSelector/Countries.h index 7fb4259..bd764ab 100644 --- a/OptionSelector/Countries.h +++ b/OptionSelector/Countries.h @@ -7,6 +7,7 @@ // #import "Categories.h" +#import @interface Countries : Categories diff --git a/OptionSelector/Food.h b/OptionSelector/Food.h index 90d300b..dd90bb9 100644 --- a/OptionSelector/Food.h +++ b/OptionSelector/Food.h @@ -7,6 +7,7 @@ // #import "Categories.h" +#import @interface Food : Categories diff --git a/OptionSelector/OptionSelectionTableViewController.h b/OptionSelector/OptionSelectionTableViewController.h index 334bc41..6c327c4 100644 --- a/OptionSelector/OptionSelectionTableViewController.h +++ b/OptionSelector/OptionSelectionTableViewController.h @@ -7,7 +7,11 @@ // #import +#import "OptionSelectionTableViewControllerDelegate.h" @interface OptionSelectionTableViewController : UITableViewController +@property (nonatomic, weak) id delegate; +@property (nonatomic) NSUInteger categoryIndex; + @end diff --git a/OptionSelector/OptionSelectionTableViewController.m b/OptionSelector/OptionSelectionTableViewController.m index 25ecbf5..415da22 100644 --- a/OptionSelector/OptionSelectionTableViewController.m +++ b/OptionSelector/OptionSelectionTableViewController.m @@ -32,69 +32,68 @@ - (void)didReceiveMemoryWarning { #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { -#warning Potentially incomplete method implementation. + // Return the number of sections. return 0; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { -#warning Incomplete method implementation. // Return the number of rows in the section. return 0; } /* -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath]; - - // Configure the cell... - - return cell; -} -*/ + - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath]; + + // Configure the cell... + + return cell; + } + */ /* -// Override to support conditional editing of the table view. -- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { - // Return NO if you do not want the specified item to be editable. - return YES; -} -*/ + // Override to support conditional editing of the table view. + - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the specified item to be editable. + return YES; + } + */ /* -// Override to support editing the table view. -- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { - if (editingStyle == UITableViewCellEditingStyleDelete) { - // Delete the row from the data source - [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; - } else if (editingStyle == UITableViewCellEditingStyleInsert) { - // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view - } -} -*/ + // Override to support editing the table view. + - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + if (editingStyle == UITableViewCellEditingStyleDelete) { + // Delete the row from the data source + [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; + } else if (editingStyle == UITableViewCellEditingStyleInsert) { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view + } + } + */ /* -// Override to support rearranging the table view. -- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { -} -*/ + // Override to support rearranging the table view. + - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { + } + */ /* -// Override to support conditional rearranging of the table view. -- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { - // Return NO if you do not want the item to be re-orderable. - return YES; -} -*/ + // Override to support conditional rearranging of the table view. + - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the item to be re-orderable. + return YES; + } + */ /* -#pragma mark - Navigation - -// In a storyboard-based application, you will often want to do a little preparation before navigation -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - // Get the new view controller using [segue destinationViewController]. - // Pass the selected object to the new view controller. -} -*/ + #pragma mark - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. + } + */ @end diff --git a/OptionSelector/OptionSelectionTableViewControllerDelegate.h b/OptionSelector/OptionSelectionTableViewControllerDelegate.h index 23020f0..d9c28f1 100644 --- a/OptionSelector/OptionSelectionTableViewControllerDelegate.h +++ b/OptionSelector/OptionSelectionTableViewControllerDelegate.h @@ -8,6 +8,9 @@ #import -@interface OptionSelectionTableViewControllerDelegate : NSObject +@class OptionSelectionTableViewController; +@protocol OptionSelectionTableViewControllerDelegate +- (void)optionSelectionTableViewController:(OptionSelectionTableViewController *)tableViewController + didSelectAnOption:(NSUInteger)cellIndex; @end diff --git a/OptionSelector/Shoes.h b/OptionSelector/Shoes.h index 83a2bd4..20ee184 100644 --- a/OptionSelector/Shoes.h +++ b/OptionSelector/Shoes.h @@ -7,6 +7,7 @@ // #import "Categories.h" +#import @interface Shoes : Categories From e3e8955392df10872a6443bc26b6d8d05ae9d588 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 12 Aug 2015 23:05:03 -0400 Subject: [PATCH 09/10] finished requirements --- OptionSelector/Base.lproj/Main.storyboard | 2 +- OptionSelector/Categories.h | 2 +- OptionSelector/CategoryTableViewController.h | 2 +- OptionSelector/CategoryTableViewController.m | 80 +++++----------- OptionSelector/Countries.m | 2 +- OptionSelector/Food.m | 2 +- .../OptionSelectionTableViewController.h | 2 +- .../OptionSelectionTableViewController.m | 96 +++++++------------ OptionSelector/Shoes.m | 2 +- 9 files changed, 63 insertions(+), 127 deletions(-) diff --git a/OptionSelector/Base.lproj/Main.storyboard b/OptionSelector/Base.lproj/Main.storyboard index b5c890e..967beee 100644 --- a/OptionSelector/Base.lproj/Main.storyboard +++ b/OptionSelector/Base.lproj/Main.storyboard @@ -73,7 +73,7 @@ - + diff --git a/OptionSelector/Categories.h b/OptionSelector/Categories.h index 5baa744..a819985 100644 --- a/OptionSelector/Categories.h +++ b/OptionSelector/Categories.h @@ -11,6 +11,6 @@ @interface Categories : NSObject @property (nonatomic) NSString *name; -@property (nonatomic) NSArray *choice; +@property (nonatomic) NSArray *choices; @property (nonatomic) NSString *selection; @end diff --git a/OptionSelector/CategoryTableViewController.h b/OptionSelector/CategoryTableViewController.h index e25d703..0bddae3 100644 --- a/OptionSelector/CategoryTableViewController.h +++ b/OptionSelector/CategoryTableViewController.h @@ -9,6 +9,6 @@ #import #import "OptionSelectionTableViewController.h" -@interface CategoryTableViewController : UITableViewController +@interface CategoryTableViewController : UITableViewController @end diff --git a/OptionSelector/CategoryTableViewController.m b/OptionSelector/CategoryTableViewController.m index bcd4a72..58c5435 100644 --- a/OptionSelector/CategoryTableViewController.m +++ b/OptionSelector/CategoryTableViewController.m @@ -6,13 +6,14 @@ // Copyright (c) 2015 Mike Kavouras. All rights reserved. // -#import "CategoryTableViewController.h" #import "CategoryMain.h" -#import "OptionSelectionTableViewcontrollerDelegate.h" +#import "CategoryTableViewController.h" +#import "OptionSelectionTableViewController.h" +#import "OptionSelectionTableViewControllerDelegate.h" @interface CategoryTableViewController () -@property (nonatomic) CategoryMain *mainCategory; +@property (nonatomic) CategoryMain *manager; @end @@ -20,10 +21,9 @@ @implementation CategoryTableViewController - (void)viewDidLoad { [super viewDidLoad]; - [self.navigationItem setTitle:@"Categories"]; - - self.mainCategory = [CategoryMain categoryManager]; + [self.navigationItem setTitle:@"Category Selection"]; + self.manager = [CategoryMain categoryManager]; } - (void)viewWillAppear:(BOOL)animated { @@ -37,69 +37,37 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. - return [self.mainCategory.categories count]; + return [self.manager.categories count]; } - - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CategoryCellIdentifier" forIndexPath:indexPath]; - cell.textLabel.text = [self.mainCategory.categories[indexPath.row] name]; - cell.detailTextLabel.text = [self.mainCategory.categories[indexPath.row] selection]; + cell.textLabel.text = [self.manager.categories[indexPath.row] name]; + cell.detailTextLabel.text = [self.manager.categories[indexPath.row] selection]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; return cell; } +-(void)optionSelectionTableViewController:(OptionSelectionTableViewController *)tableViewController didSelectAnOption:(NSUInteger)cellIndex { - /* - // Override to support conditional editing of the table view. - - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { - // Return NO if you do not want the specified item to be editable. - return YES; - } - */ - - /* - // Override to support editing the table view. - - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { - if (editingStyle == UITableViewCellEditingStyleDelete) { - // Delete the row from the data source - [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; - } else if (editingStyle == UITableViewCellEditingStyleInsert) { - // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view - } - } - */ - - /* - // Override to support rearranging the table view. - - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { - } - */ - - /* - // Override to support conditional rearranging of the table view. - - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { - // Return NO if you do not want the item to be re-orderable. - return YES; - } - */ + NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; + Categories *category = self.manager.categories[indexPath.row]; + [category setSelection:category.choices[cellIndex]]; + NSLog(@"%@", category.choices[cellIndex]); +} + +#pragma mark - Navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; -#pragma mark - Navigation - - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - - NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; - - OptionSelectionTableViewController *optionSelectors = [segue destinationViewController]; - optionSelectors.categoryIndex = indexPath.row; - optionSelectors.delegate = (id) self; - } - - + OptionSelectionTableViewController *optionSelectors = [segue destinationViewController]; + optionSelectors.categoryIndex = indexPath.row; + optionSelectors.delegate = (id) self; +} - @end +@end diff --git a/OptionSelector/Countries.m b/OptionSelector/Countries.m index b4ae768..0301800 100644 --- a/OptionSelector/Countries.m +++ b/OptionSelector/Countries.m @@ -12,7 +12,7 @@ @implementation Countries - (instancetype)init { if (self = [super init]) { - self.choice = @[@"South Korea", @"France", @"Japan", @"Spain", @"Maine", @"California"]; + self.choices = @[@"South Korea", @"France", @"Japan", @"Spain", @"Paraguay", @"Guam"]; self.name = @"Places"; } return self; diff --git a/OptionSelector/Food.m b/OptionSelector/Food.m index 87cb4cb..c1e7f6b 100644 --- a/OptionSelector/Food.m +++ b/OptionSelector/Food.m @@ -12,7 +12,7 @@ @implementation Food - (instancetype)init { if (self = [super init]) { - self.choice = @[@"Pizza", @"Pasta", @"Linguine", @"Ravioli", @"Krabby Patty", @"Rainbow Patty"]; + self.choices = @[@"Pizza", @"Pasta", @"Linguine", @"Ravioli", @"Krabby Patty", @"Rainbow Patty"]; self.name = @"Food"; } return self; diff --git a/OptionSelector/OptionSelectionTableViewController.h b/OptionSelector/OptionSelectionTableViewController.h index 6c327c4..249f6b0 100644 --- a/OptionSelector/OptionSelectionTableViewController.h +++ b/OptionSelector/OptionSelectionTableViewController.h @@ -9,7 +9,7 @@ #import #import "OptionSelectionTableViewControllerDelegate.h" -@interface OptionSelectionTableViewController : UITableViewController +@interface OptionSelectionTableViewController : UITableViewController @property (nonatomic, weak) id delegate; @property (nonatomic) NSUInteger categoryIndex; diff --git a/OptionSelector/OptionSelectionTableViewController.m b/OptionSelector/OptionSelectionTableViewController.m index 415da22..89e3bea 100644 --- a/OptionSelector/OptionSelectionTableViewController.m +++ b/OptionSelector/OptionSelectionTableViewController.m @@ -7,9 +7,13 @@ // #import "OptionSelectionTableViewController.h" +#import "CategoryMain.h" @interface OptionSelectionTableViewController () +@property (nonatomic) CategoryMain *manager; +@property (nonatomic) NSArray *choices; + @end @implementation OptionSelectionTableViewController @@ -17,16 +21,9 @@ @implementation OptionSelectionTableViewController - (void)viewDidLoad { [super viewDidLoad]; - // Uncomment the following line to preserve selection between presentations. - // self.clearsSelectionOnViewWillAppear = NO; - - // Uncomment the following line to display an Edit button in the navigation bar for this view controller. - // self.navigationItem.rightBarButtonItem = self.editButtonItem; -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. + self.manager = [CategoryMain categoryManager]; + self.choices = [self.manager.categories[self.categoryIndex] choices]; + [self.navigationItem setTitle:@"Chooserino"]; } #pragma mark - Table view data source @@ -34,66 +31,37 @@ - (void)didReceiveMemoryWarning { - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. - return 0; + return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. - return 0; + return [self.choices count]; } -/* - - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath]; - - // Configure the cell... - - return cell; - } - */ - -/* - // Override to support conditional editing of the table view. - - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { - // Return NO if you do not want the specified item to be editable. - return YES; - } - */ - -/* - // Override to support editing the table view. - - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { - if (editingStyle == UITableViewCellEditingStyleDelete) { - // Delete the row from the data source - [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; - } else if (editingStyle == UITableViewCellEditingStyleInsert) { - // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view - } - } - */ - -/* - // Override to support rearranging the table view. - - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { - } - */ +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [self.delegate optionSelectionTableViewController:self didSelectAnOption:indexPath.row]; + [tableView reloadData]; +} -/* - // Override to support conditional rearranging of the table view. - - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { - // Return NO if you do not want the item to be re-orderable. - return YES; - } - */ -/* - #pragma mark - Navigation - - // In a storyboard-based application, you will often want to do a little preparation before navigation - - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - // Get the new view controller using [segue destinationViewController]. - // Pass the selected object to the new view controller. - } - */ +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellChoiceIdentifier" forIndexPath:indexPath]; + + // Configure the cell... + NSString *choice = self.choices[indexPath.row]; + cell.textLabel.text = choice; + + Categories *category = self.manager.categories[self.categoryIndex]; + NSString *selectedChoice = [category selection]; + + if ([selectedChoice isEqualToString:choice]) { + [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; + } else { + [cell setAccessoryType:UITableViewCellAccessoryNone]; + } + + return cell; +} -@end +@end \ No newline at end of file diff --git a/OptionSelector/Shoes.m b/OptionSelector/Shoes.m index 88083c1..a5872d3 100644 --- a/OptionSelector/Shoes.m +++ b/OptionSelector/Shoes.m @@ -12,7 +12,7 @@ @implementation Shoes - (instancetype)init { if (self = [super init]) { - self.choice = @[@"Nike", @"Saucony", @"Adidas", @"Reebok", @"Timberland", @"Uggs"]; + self.choices = @[@"Nike", @"Saucony", @"Adidas", @"Reebok", @"Timberland", @"Uggs"]; self.name = @"Shoes"; } return self; From 82ba54851743aa7f7bb10f5275ebc0562269a826 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 14 Aug 2015 23:18:11 -0400 Subject: [PATCH 10/10] added some comments --- OptionSelector/Categories.h | 1 + 1 file changed, 1 insertion(+) diff --git a/OptionSelector/Categories.h b/OptionSelector/Categories.h index a819985..51e4c93 100644 --- a/OptionSelector/Categories.h +++ b/OptionSelector/Categories.h @@ -13,4 +13,5 @@ @property (nonatomic) NSString *name; @property (nonatomic) NSArray *choices; @property (nonatomic) NSString *selection; + @end