-
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
KPicart-HW4 #18
base: master
Are you sure you want to change the base?
KPicart-HW4 #18
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// KPAddItemTableViewController.h | ||
// NavViewsAndOptionSelector | ||
// | ||
// Created by MacMan on 8/14/15. | ||
// Copyright (c) 2015 MacManApp. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@class KPIndexListTableViewController; | ||
|
||
|
||
@interface KPAddItemTableViewController : UITableViewController | ||
|
||
-(IBAction)cancelButtonPressed:(id)sender; | ||
-(IBAction)doneButtonPressed:(id)sender; | ||
|
||
@property (nonatomic, strong)IBOutlet UITextField *nameField; | ||
|
||
@property (nonatomic, strong)KPIndexListTableViewController *indexListTableViewController; | ||
|
||
|
||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// KPAddItemTableViewController.m | ||
// NavViewsAndOptionSelector | ||
// | ||
// Created by MacMan on 8/14/15. | ||
// Copyright (c) 2015 MacManApp. All rights reserved. | ||
// | ||
|
||
#import "KPAddItemTableViewController.h" | ||
#import "KPIndexListTableViewController.h" | ||
#import "KPIndex.h" | ||
|
||
|
||
@interface KPAddItemTableViewController () | ||
|
||
@end | ||
|
||
@implementation KPAddItemTableViewController | ||
|
||
@synthesize nameField = _nameField; | ||
@synthesize indexListTableViewController = _indexListTableViewController; | ||
|
||
|
||
- (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 - IBActions | ||
|
||
-(void)cancelButtonPressed:(id)sender{ | ||
|
||
[self dismissViewControllerAnimated:YES completion:nil]; | ||
|
||
} | ||
|
||
-(void) doneButtonPressed:(id)sender{ | ||
KPIndex *newItem = [[KPIndex alloc] initWithName:self.nameField.text done:NO]; | ||
|
||
|
||
[self.indexListTableViewController.indexArray addObject:newItem]; | ||
|
||
|
||
|
||
[self dismissViewControllerAnimated:YES completion:nil]; | ||
|
||
} | ||
|
||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// KPEditItemTableViewController.h | ||
// NavViewsAndOptionSelector | ||
// | ||
// Created by MacMan on 8/14/15. | ||
// Copyright (c) 2015 MacManApp. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@class KPIndex; | ||
|
||
@interface KPEditItemTableViewController : UITableViewController | ||
|
||
|
||
@property (nonatomic, strong) IBOutlet UITextField *nameField; | ||
@property (nonatomic, strong) IBOutlet UISwitch *doneSwitch; | ||
|
||
@property (nonatomic, strong) KPIndex *item; | ||
|
||
|
||
|
||
-(IBAction)itemDataChanged:(id)sender; | ||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// KPEditItemTableViewController.m | ||
// NavViewsAndOptionSelector | ||
// | ||
// Created by MacMan on 8/14/15. | ||
// Copyright (c) 2015 MacManApp. All rights reserved. | ||
// | ||
|
||
#import "KPEditItemTableViewController.h" | ||
#import "KPIndex.h" | ||
|
||
@interface KPEditItemTableViewController () | ||
|
||
@end | ||
|
||
@implementation KPEditItemTableViewController | ||
|
||
@synthesize nameField = _nameField; | ||
@synthesize doneSwitch = _doneSwitch; | ||
@synthesize item = _item; | ||
|
||
|
||
|
||
|
||
|
||
- (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; | ||
|
||
|
||
self.nameField.text = self.item.name; | ||
[self.doneSwitch setOn: self.item.done]; | ||
|
||
|
||
|
||
} | ||
|
||
- (void)didReceiveMemoryWarning { | ||
[super didReceiveMemoryWarning]; | ||
// Dispose of any resources that can be recreated. | ||
} | ||
|
||
#pragma mark -IBActions | ||
|
||
-(void)itemDataChanged:(id)sender { | ||
|
||
self.item.name = self.nameField.text; | ||
self.item.done = self.doneSwitch.isOn; | ||
|
||
|
||
} | ||
|
||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// KPIndex.h | ||
// NavViewsAndOptionSelector | ||
// | ||
// Created by MacMan on 8/14/15. | ||
// Copyright (c) 2015 MacManApp. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface KPIndex : UIViewController | ||
|
||
|
||
@property (nonatomic, strong) NSString *name; | ||
@property (nonatomic, assign)BOOL done; | ||
|
||
-(id)initWithName:(NSString *)name done:(BOOL)done; | ||
|
||
|
||
|
||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | ||
// KPIndex.m | ||
// NavViewsAndOptionSelector | ||
// | ||
// Created by MacMan on 8/14/15. | ||
// Copyright (c) 2015 MacManApp. All rights reserved. | ||
// | ||
|
||
#import "KPIndex.h" | ||
|
||
@interface KPIndex () | ||
|
||
@end | ||
|
||
|
||
@implementation KPIndex | ||
@synthesize name = _name; | ||
@synthesize done = _done; | ||
|
||
|
||
-(id)initWithName:(NSString *)name done:(BOOL)done { | ||
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. Like the custom initializer method. :D |
||
self = [super init]; | ||
|
||
if (self){ | ||
self.name = name; | ||
self.done = done; | ||
|
||
|
||
} | ||
|
||
return self; | ||
|
||
} | ||
|
||
|
||
|
||
@end | ||
|
||
|
||
|
||
|
||
//@implementation KPIndex | ||
// | ||
//- (void)viewDidLoad { | ||
// [super viewDidLoad]; | ||
// // Do any additional setup after loading the view. | ||
//} | ||
// | ||
//- (void)didReceiveMemoryWarning { | ||
// [super didReceiveMemoryWarning]; | ||
// // Dispose of any resources that can be recreated. | ||
//} | ||
// | ||
///* | ||
//#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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// KPIndexListTableViewController.h | ||
// NavViewsAndOptionSelector | ||
// | ||
// Created by MacMan on 8/14/15. | ||
// Copyright (c) 2015 MacManApp. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface KPIndexListTableViewController : UITableViewController | ||
|
||
@property (nonatomic,strong) NSMutableArray *indexArray; | ||
|
||
|
||
@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 does
KPIndex
inherit fromUIViewController
? It doesn't seem to act as a view controller, but rather as a simple object with a couple of properties. I'd suggest making it inherit fromNSObject
instead.Also, I'm a bit confused by the naming choice. An
index
is most frequently used to refer to an integer denoting the position of an element in a sequence or other data structure, not the element itself. If you want a generic name for an element in a list, something likeListItem
orElement
would be more descriptive.