-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lauren Caponong homework #22
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// CQCategory.h | ||
// OptionSelector | ||
// | ||
// Created by Lauren Caponong on 8/11/15. | ||
// Copyright (c) 2015 Mike Kavouras. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface CQCategory : NSObject | ||
|
||
@property (nonatomic) NSString *name; | ||
@property (nonatomic) NSArray *options; | ||
@property (nonatomic) NSString *selection; | ||
|
||
- (void)initializeData; | ||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// CQCategory.m | ||
// OptionSelector | ||
// | ||
// Created by Lauren Caponong on 8/11/15. | ||
// Copyright (c) 2015 Mike Kavouras. All rights reserved. | ||
// | ||
|
||
#import "CQCategory.h" | ||
|
||
@implementation CQCategory | ||
|
||
- (void)initializeData { | ||
|
||
[self name]; | ||
[self options]; | ||
[self selection]; | ||
} | ||
|
||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// AnimalDetailTableViewController.h | ||
// OptionSelector | ||
// | ||
// Created by Lauren Caponong on 8/11/15. | ||
// Copyright (c) 2015 Mike Kavouras. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "CQCategory.h" | ||
|
||
@class AnimalDetailTableViewController; | ||
|
||
@protocol ViewControllerAnimalDetailTableViewDelegate <NSObject> | ||
- (void)addItemViewController:(AnimalDetailTableViewController *)controller didFinishEnteringItem:(CQCategory *)item; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice work with the delegate protocol! |
||
@end | ||
|
||
|
||
|
||
|
||
@interface AnimalDetailTableViewController : UITableViewController | ||
|
||
@property (nonatomic) CQCategory *thing; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's best to use variable names that are as specific as possible. Usually names like |
||
@property (nonatomic, weak) id <ViewControllerAnimalDetailTableViewDelegate> delegate; | ||
|
||
@property (nonatomic, retain) NSString *selectedThing; | ||
|
||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// | ||
// AnimalDetailTableViewController.m | ||
// OptionSelector | ||
// | ||
// Created by Lauren Caponong on 8/11/15. | ||
// Copyright (c) 2015 Mike Kavouras. All rights reserved. | ||
// | ||
|
||
#import "AnimalDetailTableViewController.h" | ||
#import "CQCategory.h" | ||
|
||
@interface AnimalDetailTableViewController () | ||
|
||
@property (nonatomic) NSMutableArray *array2; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comment https://github.com/accesscode-2-2/unit-1-hw-week-4/pull/22/files#r37153501 re: variable naming. |
||
|
||
|
||
@end | ||
|
||
|
||
|
||
|
||
@implementation AnimalDetailTableViewController | ||
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
|
||
|
||
CQCategory *dog = [[CQCategory alloc] init]; | ||
CQCategory *cat = [[CQCategory alloc] init]; | ||
CQCategory *bug = [[CQCategory alloc] init]; | ||
|
||
dog.name = @"Dog"; | ||
cat.name = @"Cat"; | ||
bug.name = @"Bug"; | ||
|
||
[self.array2 addObject:dog]; | ||
[self.array2 addObject:cat]; | ||
[self.array2 addObject:bug]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does your |
||
|
||
|
||
} | ||
|
||
- (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.thing.options.count; | ||
} | ||
|
||
|
||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | ||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AnimalTypesIdentifier2" forIndexPath:indexPath]; | ||
|
||
NSString *name = self.thing.options[indexPath.row]; | ||
|
||
cell.textLabel.text = name; | ||
|
||
NSString *itemToPassBack = @"PASS"; | ||
[self.delegate addItemViewController:self didFinishEnteringItem:itemToPassBack]; | ||
|
||
return cell; | ||
} | ||
|
||
|
||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath | ||
{ | ||
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark; | ||
|
||
self.thing.selection = self.thing.options[indexPath.row]; | ||
|
||
[self.delegate addItemViewController:self didFinishEnteringItem:self.thing]; | ||
|
||
} | ||
|
||
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath | ||
{ | ||
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryNone; | ||
} | ||
|
||
|
||
|
||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// AnimalTypesTableViewController.h | ||
// OptionSelector | ||
// | ||
// Created by Lauren Caponong on 8/11/15. | ||
// Copyright (c) 2015 Mike Kavouras. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "AnimalDetailTableViewController.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this |
||
|
||
|
||
@interface AnimalTypesTableViewController : UITableViewController | ||
|
||
@end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this method necessary? Since it doesn't actually affect the state of the code. :D