From 9ef8424da4f3b6880692db94a280b446776b85f1 Mon Sep 17 00:00:00 2001 From: Natalia Estrella Date: Fri, 9 Oct 2015 00:38:15 -0400 Subject: [PATCH 1/3] WIP --- MarsWater/MarsWater.xcodeproj/project.pbxproj | 55 +++++---- .../MarsWater/Base.lproj/Main.storyboard | 115 +++++++++++++++++- .../MarsWater/ListsTableViewController.m | 5 + .../MarsWater.xcdatamodel/contents | 6 +- .../MarsWater/TaskListTableViewController.h | 13 ++ .../MarsWater/TaskListTableViewController.m | 104 ++++++++++++++++ 6 files changed, 266 insertions(+), 32 deletions(-) create mode 100644 MarsWater/MarsWater/TaskListTableViewController.h create mode 100644 MarsWater/MarsWater/TaskListTableViewController.m diff --git a/MarsWater/MarsWater.xcodeproj/project.pbxproj b/MarsWater/MarsWater.xcodeproj/project.pbxproj index 61d423d..370218d 100644 --- a/MarsWater/MarsWater.xcodeproj/project.pbxproj +++ b/MarsWater/MarsWater.xcodeproj/project.pbxproj @@ -7,21 +7,32 @@ objects = { /* Begin PBXBuildFile section */ + 5133F2D51BC21ADE0001A8EB /* List.m in Sources */ = {isa = PBXBuildFile; fileRef = 5133F2CE1BC21ADE0001A8EB /* List.m */; settings = {ASSET_TAGS = (); }; }; + 5133F2D61BC21ADE0001A8EB /* List+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 5133F2D01BC21ADE0001A8EB /* List+CoreDataProperties.m */; settings = {ASSET_TAGS = (); }; }; + 5133F2D71BC21ADE0001A8EB /* Task.m in Sources */ = {isa = PBXBuildFile; fileRef = 5133F2D21BC21ADE0001A8EB /* Task.m */; settings = {ASSET_TAGS = (); }; }; + 5133F2D81BC21ADE0001A8EB /* Task+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 5133F2D41BC21ADE0001A8EB /* Task+CoreDataProperties.m */; settings = {ASSET_TAGS = (); }; }; + 5133F2DB1BC2219A0001A8EB /* TaskListTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5133F2DA1BC2219A0001A8EB /* TaskListTableViewController.m */; settings = {ASSET_TAGS = (); }; }; 8DA86CA91BC1AE57006C50BC /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DA86CA81BC1AE57006C50BC /* main.m */; }; 8DA86CAC1BC1AE57006C50BC /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DA86CAB1BC1AE57006C50BC /* AppDelegate.m */; }; 8DA86CB21BC1AE57006C50BC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8DA86CB01BC1AE57006C50BC /* Main.storyboard */; }; 8DA86CB51BC1AE57006C50BC /* MarsWater.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 8DA86CB31BC1AE57006C50BC /* MarsWater.xcdatamodeld */; }; 8DA86CB71BC1AE57006C50BC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8DA86CB61BC1AE57006C50BC /* Assets.xcassets */; }; 8DA86CBA1BC1AE57006C50BC /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8DA86CB81BC1AE57006C50BC /* LaunchScreen.storyboard */; }; - 8DA86CCD1BC1B31C006C50BC /* List+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DA86CC61BC1B31C006C50BC /* List+CoreDataProperties.m */; settings = {ASSET_TAGS = (); }; }; - 8DA86CCE1BC1B31C006C50BC /* List.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DA86CC81BC1B31C006C50BC /* List.m */; settings = {ASSET_TAGS = (); }; }; - 8DA86CCF1BC1B31C006C50BC /* Task+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DA86CCA1BC1B31C006C50BC /* Task+CoreDataProperties.m */; settings = {ASSET_TAGS = (); }; }; - 8DA86CD01BC1B31C006C50BC /* Task.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DA86CCC1BC1B31C006C50BC /* Task.m */; settings = {ASSET_TAGS = (); }; }; 8DA86CD41BC1B8E4006C50BC /* ListsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DA86CD31BC1B8E4006C50BC /* ListsTableViewController.m */; settings = {ASSET_TAGS = (); }; }; 8DA86CD71BC1B904006C50BC /* ListCreationTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DA86CD61BC1B904006C50BC /* ListCreationTableViewController.m */; settings = {ASSET_TAGS = (); }; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 5133F2CD1BC21ADE0001A8EB /* List.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = List.h; sourceTree = ""; }; + 5133F2CE1BC21ADE0001A8EB /* List.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = List.m; sourceTree = ""; }; + 5133F2CF1BC21ADE0001A8EB /* List+CoreDataProperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "List+CoreDataProperties.h"; sourceTree = ""; }; + 5133F2D01BC21ADE0001A8EB /* List+CoreDataProperties.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "List+CoreDataProperties.m"; sourceTree = ""; }; + 5133F2D11BC21ADE0001A8EB /* Task.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Task.h; sourceTree = ""; }; + 5133F2D21BC21ADE0001A8EB /* Task.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Task.m; sourceTree = ""; }; + 5133F2D31BC21ADE0001A8EB /* Task+CoreDataProperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Task+CoreDataProperties.h"; sourceTree = ""; }; + 5133F2D41BC21ADE0001A8EB /* Task+CoreDataProperties.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "Task+CoreDataProperties.m"; sourceTree = ""; }; + 5133F2D91BC2219A0001A8EB /* TaskListTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TaskListTableViewController.h; sourceTree = ""; }; + 5133F2DA1BC2219A0001A8EB /* TaskListTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TaskListTableViewController.m; sourceTree = ""; }; 8DA86CA41BC1AE57006C50BC /* MarsWater.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MarsWater.app; sourceTree = BUILT_PRODUCTS_DIR; }; 8DA86CA81BC1AE57006C50BC /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 8DA86CAA1BC1AE57006C50BC /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; @@ -31,14 +42,6 @@ 8DA86CB61BC1AE57006C50BC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 8DA86CB91BC1AE57006C50BC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 8DA86CBB1BC1AE57006C50BC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 8DA86CC51BC1B31C006C50BC /* List+CoreDataProperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "List+CoreDataProperties.h"; path = "../List+CoreDataProperties.h"; sourceTree = ""; }; - 8DA86CC61BC1B31C006C50BC /* List+CoreDataProperties.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "List+CoreDataProperties.m"; path = "../List+CoreDataProperties.m"; sourceTree = ""; }; - 8DA86CC71BC1B31C006C50BC /* List.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = List.h; path = ../List.h; sourceTree = ""; }; - 8DA86CC81BC1B31C006C50BC /* List.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = List.m; path = ../List.m; sourceTree = ""; }; - 8DA86CC91BC1B31C006C50BC /* Task+CoreDataProperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "Task+CoreDataProperties.h"; path = "../Task+CoreDataProperties.h"; sourceTree = ""; }; - 8DA86CCA1BC1B31C006C50BC /* Task+CoreDataProperties.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "Task+CoreDataProperties.m"; path = "../Task+CoreDataProperties.m"; sourceTree = ""; }; - 8DA86CCB1BC1B31C006C50BC /* Task.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Task.h; path = ../Task.h; sourceTree = ""; }; - 8DA86CCC1BC1B31C006C50BC /* Task.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Task.m; path = ../Task.m; sourceTree = ""; }; 8DA86CD21BC1B8E4006C50BC /* ListsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ListsTableViewController.h; sourceTree = ""; }; 8DA86CD31BC1B8E4006C50BC /* ListsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ListsTableViewController.m; sourceTree = ""; }; 8DA86CD51BC1B904006C50BC /* ListCreationTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ListCreationTableViewController.h; sourceTree = ""; }; @@ -83,6 +86,8 @@ 8DA86CD51BC1B904006C50BC /* ListCreationTableViewController.h */, 8DA86CD61BC1B904006C50BC /* ListCreationTableViewController.m */, 8DA86CB01BC1AE57006C50BC /* Main.storyboard */, + 5133F2D91BC2219A0001A8EB /* TaskListTableViewController.h */, + 5133F2DA1BC2219A0001A8EB /* TaskListTableViewController.m */, 8DA86CB61BC1AE57006C50BC /* Assets.xcassets */, 8DA86CB81BC1AE57006C50BC /* LaunchScreen.storyboard */, 8DA86CBB1BC1AE57006C50BC /* Info.plist */, @@ -103,14 +108,14 @@ 8DA86CD11BC1B329006C50BC /* Model */ = { isa = PBXGroup; children = ( - 8DA86CC51BC1B31C006C50BC /* List+CoreDataProperties.h */, - 8DA86CC61BC1B31C006C50BC /* List+CoreDataProperties.m */, - 8DA86CC71BC1B31C006C50BC /* List.h */, - 8DA86CC81BC1B31C006C50BC /* List.m */, - 8DA86CC91BC1B31C006C50BC /* Task+CoreDataProperties.h */, - 8DA86CCA1BC1B31C006C50BC /* Task+CoreDataProperties.m */, - 8DA86CCB1BC1B31C006C50BC /* Task.h */, - 8DA86CCC1BC1B31C006C50BC /* Task.m */, + 5133F2CD1BC21ADE0001A8EB /* List.h */, + 5133F2CE1BC21ADE0001A8EB /* List.m */, + 5133F2CF1BC21ADE0001A8EB /* List+CoreDataProperties.h */, + 5133F2D01BC21ADE0001A8EB /* List+CoreDataProperties.m */, + 5133F2D11BC21ADE0001A8EB /* Task.h */, + 5133F2D21BC21ADE0001A8EB /* Task.m */, + 5133F2D31BC21ADE0001A8EB /* Task+CoreDataProperties.h */, + 5133F2D41BC21ADE0001A8EB /* Task+CoreDataProperties.m */, ); name = Model; sourceTree = ""; @@ -186,13 +191,14 @@ buildActionMask = 2147483647; files = ( 8DA86CB51BC1AE57006C50BC /* MarsWater.xcdatamodeld in Sources */, - 8DA86CCF1BC1B31C006C50BC /* Task+CoreDataProperties.m in Sources */, 8DA86CAC1BC1AE57006C50BC /* AppDelegate.m in Sources */, + 5133F2D61BC21ADE0001A8EB /* List+CoreDataProperties.m in Sources */, + 5133F2D71BC21ADE0001A8EB /* Task.m in Sources */, + 5133F2DB1BC2219A0001A8EB /* TaskListTableViewController.m in Sources */, 8DA86CD41BC1B8E4006C50BC /* ListsTableViewController.m in Sources */, - 8DA86CD01BC1B31C006C50BC /* Task.m in Sources */, - 8DA86CCE1BC1B31C006C50BC /* List.m in Sources */, + 5133F2D51BC21ADE0001A8EB /* List.m in Sources */, 8DA86CD71BC1B904006C50BC /* ListCreationTableViewController.m in Sources */, - 8DA86CCD1BC1B31C006C50BC /* List+CoreDataProperties.m in Sources */, + 5133F2D81BC21ADE0001A8EB /* Task+CoreDataProperties.m in Sources */, 8DA86CA91BC1AE57006C50BC /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -340,6 +346,7 @@ 8DA86CC01BC1AE57006C50BC /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ diff --git a/MarsWater/MarsWater/Base.lproj/Main.storyboard b/MarsWater/MarsWater/Base.lproj/Main.storyboard index 13ead89..9e4df7c 100644 --- a/MarsWater/MarsWater/Base.lproj/Main.storyboard +++ b/MarsWater/MarsWater/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -14,11 +14,11 @@ - + - + + + + @@ -60,6 +63,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -75,7 +180,7 @@ - + @@ -213,7 +318,7 @@ - + diff --git a/MarsWater/MarsWater/ListsTableViewController.m b/MarsWater/MarsWater/ListsTableViewController.m index 8a2659c..4032add 100644 --- a/MarsWater/MarsWater/ListsTableViewController.m +++ b/MarsWater/MarsWater/ListsTableViewController.m @@ -72,5 +72,10 @@ - (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id) [self.tableView reloadData]; } +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ + +} + @end diff --git a/MarsWater/MarsWater/MarsWater.xcdatamodeld/MarsWater.xcdatamodel/contents b/MarsWater/MarsWater/MarsWater.xcdatamodeld/MarsWater.xcdatamodel/contents index 116441d..a813449 100644 --- a/MarsWater/MarsWater/MarsWater.xcdatamodeld/MarsWater.xcdatamodel/contents +++ b/MarsWater/MarsWater/MarsWater.xcdatamodeld/MarsWater.xcdatamodel/contents @@ -1,10 +1,10 @@ - + - + @@ -16,7 +16,7 @@ - + \ No newline at end of file diff --git a/MarsWater/MarsWater/TaskListTableViewController.h b/MarsWater/MarsWater/TaskListTableViewController.h new file mode 100644 index 0000000..cc057e5 --- /dev/null +++ b/MarsWater/MarsWater/TaskListTableViewController.h @@ -0,0 +1,13 @@ +// +// TaskListTableViewController.h +// MarsWater +// +// Created by Natalia Estrella on 10/4/15. +// Copyright © 2015 Michael Kavouras. All rights reserved. +// + +#import + +@interface TaskListTableViewController : UITableViewController + +@end diff --git a/MarsWater/MarsWater/TaskListTableViewController.m b/MarsWater/MarsWater/TaskListTableViewController.m new file mode 100644 index 0000000..9753a2e --- /dev/null +++ b/MarsWater/MarsWater/TaskListTableViewController.m @@ -0,0 +1,104 @@ +// +// TaskListTableViewController.m +// MarsWater +// +// Created by Natalia Estrella on 10/4/15. +// Copyright © 2015 Michael Kavouras. All rights reserved. +// + +#import "TaskListTableViewController.h" + +@interface TaskListTableViewController () + +@end + +@implementation TaskListTableViewController + +- (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 Incomplete implementation, return the number of sections + return 0; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { +#warning Incomplete implementation, return the number of rows + return 0; +} + +- (IBAction)backTapped:(id)sender { + [self dismissViewControllerAnimated:YES completion:nil]; +} + +/* +- (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 3407567960680cb562d57570e1a69d658d4aadcf Mon Sep 17 00:00:00 2001 From: Natalia Estrella Date: Fri, 9 Oct 2015 01:00:22 -0400 Subject: [PATCH 2/3] Segue implementation --- .../MarsWater/Base.lproj/Main.storyboard | 104 ++++++------------ .../MarsWater/ListsTableViewController.m | 8 +- .../MarsWater/TaskListTableViewController.h | 3 + .../MarsWater/TaskListTableViewController.m | 4 - 4 files changed, 44 insertions(+), 75 deletions(-) diff --git a/MarsWater/MarsWater/Base.lproj/Main.storyboard b/MarsWater/MarsWater/Base.lproj/Main.storyboard index 9e4df7c..b128c95 100644 --- a/MarsWater/MarsWater/Base.lproj/Main.storyboard +++ b/MarsWater/MarsWater/Base.lproj/Main.storyboard @@ -2,6 +2,7 @@ + @@ -42,7 +43,7 @@ - + @@ -87,83 +88,16 @@ - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -320,6 +254,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MarsWater/MarsWater/ListsTableViewController.m b/MarsWater/MarsWater/ListsTableViewController.m index 4032add..e2aeecf 100644 --- a/MarsWater/MarsWater/ListsTableViewController.m +++ b/MarsWater/MarsWater/ListsTableViewController.m @@ -10,6 +10,7 @@ #import "ListsTableViewController.h" #import "AppDelegate.h" #import "List.h" +#import "TaskListTableViewController.h" @interface ListsTableViewController () @@ -74,7 +75,12 @@ - (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id) - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - + TaskListTableViewController *vc = [segue destinationViewController]; + + NSIndexPath *indexPath = [self.tableView indexPathForCell:sender]; + + vc.task = self.fetchedResultsController.fetchedObjects[indexPath.row]; + } @end diff --git a/MarsWater/MarsWater/TaskListTableViewController.h b/MarsWater/MarsWater/TaskListTableViewController.h index cc057e5..fc31436 100644 --- a/MarsWater/MarsWater/TaskListTableViewController.h +++ b/MarsWater/MarsWater/TaskListTableViewController.h @@ -7,7 +7,10 @@ // #import +#import "Task.h" @interface TaskListTableViewController : UITableViewController +@property (nonatomic) Task *task; + @end diff --git a/MarsWater/MarsWater/TaskListTableViewController.m b/MarsWater/MarsWater/TaskListTableViewController.m index 9753a2e..2f109bf 100644 --- a/MarsWater/MarsWater/TaskListTableViewController.m +++ b/MarsWater/MarsWater/TaskListTableViewController.m @@ -43,10 +43,6 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger return 0; } -- (IBAction)backTapped:(id)sender { - [self dismissViewControllerAnimated:YES completion:nil]; -} - /* - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath]; From 06214b6a763378872c3eba3073b4d52a962b592c Mon Sep 17 00:00:00 2001 From: Natalia Estrella Date: Fri, 9 Oct 2015 21:29:28 -0400 Subject: [PATCH 3/3] OMG death from above... in mars --- MarsWater/MarsWater.xcodeproj/project.pbxproj | 6 ++ .../Base.lproj/LaunchScreen.storyboard | 4 +- .../MarsWater/Base.lproj/Main.storyboard | 55 ++++++++++- .../MarsWater/ListsTableViewController.m | 13 ++- .../MarsWater/TaskCreationViewController.h | 13 +++ .../MarsWater/TaskCreationViewController.m | 45 +++++++++ .../MarsWater/TaskListTableViewController.m | 99 ++++++++----------- 7 files changed, 167 insertions(+), 68 deletions(-) create mode 100644 MarsWater/MarsWater/TaskCreationViewController.h create mode 100644 MarsWater/MarsWater/TaskCreationViewController.m diff --git a/MarsWater/MarsWater.xcodeproj/project.pbxproj b/MarsWater/MarsWater.xcodeproj/project.pbxproj index 370218d..8c80ba7 100644 --- a/MarsWater/MarsWater.xcodeproj/project.pbxproj +++ b/MarsWater/MarsWater.xcodeproj/project.pbxproj @@ -12,6 +12,7 @@ 5133F2D71BC21ADE0001A8EB /* Task.m in Sources */ = {isa = PBXBuildFile; fileRef = 5133F2D21BC21ADE0001A8EB /* Task.m */; settings = {ASSET_TAGS = (); }; }; 5133F2D81BC21ADE0001A8EB /* Task+CoreDataProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 5133F2D41BC21ADE0001A8EB /* Task+CoreDataProperties.m */; settings = {ASSET_TAGS = (); }; }; 5133F2DB1BC2219A0001A8EB /* TaskListTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5133F2DA1BC2219A0001A8EB /* TaskListTableViewController.m */; settings = {ASSET_TAGS = (); }; }; + 518510531BC89D8A00A45E70 /* TaskCreationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 518510521BC89D8A00A45E70 /* TaskCreationViewController.m */; settings = {ASSET_TAGS = (); }; }; 8DA86CA91BC1AE57006C50BC /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DA86CA81BC1AE57006C50BC /* main.m */; }; 8DA86CAC1BC1AE57006C50BC /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DA86CAB1BC1AE57006C50BC /* AppDelegate.m */; }; 8DA86CB21BC1AE57006C50BC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8DA86CB01BC1AE57006C50BC /* Main.storyboard */; }; @@ -33,6 +34,8 @@ 5133F2D41BC21ADE0001A8EB /* Task+CoreDataProperties.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "Task+CoreDataProperties.m"; sourceTree = ""; }; 5133F2D91BC2219A0001A8EB /* TaskListTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TaskListTableViewController.h; sourceTree = ""; }; 5133F2DA1BC2219A0001A8EB /* TaskListTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TaskListTableViewController.m; sourceTree = ""; }; + 518510511BC89D8A00A45E70 /* TaskCreationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TaskCreationViewController.h; sourceTree = ""; }; + 518510521BC89D8A00A45E70 /* TaskCreationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TaskCreationViewController.m; sourceTree = ""; }; 8DA86CA41BC1AE57006C50BC /* MarsWater.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MarsWater.app; sourceTree = BUILT_PRODUCTS_DIR; }; 8DA86CA81BC1AE57006C50BC /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 8DA86CAA1BC1AE57006C50BC /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; @@ -93,6 +96,8 @@ 8DA86CBB1BC1AE57006C50BC /* Info.plist */, 8DA86CB31BC1AE57006C50BC /* MarsWater.xcdatamodeld */, 8DA86CA71BC1AE57006C50BC /* Supporting Files */, + 518510511BC89D8A00A45E70 /* TaskCreationViewController.h */, + 518510521BC89D8A00A45E70 /* TaskCreationViewController.m */, ); path = MarsWater; sourceTree = ""; @@ -194,6 +199,7 @@ 8DA86CAC1BC1AE57006C50BC /* AppDelegate.m in Sources */, 5133F2D61BC21ADE0001A8EB /* List+CoreDataProperties.m in Sources */, 5133F2D71BC21ADE0001A8EB /* Task.m in Sources */, + 518510531BC89D8A00A45E70 /* TaskCreationViewController.m in Sources */, 5133F2DB1BC2219A0001A8EB /* TaskListTableViewController.m in Sources */, 8DA86CD41BC1B8E4006C50BC /* ListsTableViewController.m in Sources */, 5133F2D51BC21ADE0001A8EB /* List.m in Sources */, diff --git a/MarsWater/MarsWater/Base.lproj/LaunchScreen.storyboard b/MarsWater/MarsWater/Base.lproj/LaunchScreen.storyboard index 2e721e1..5a9c4a6 100644 --- a/MarsWater/MarsWater/Base.lproj/LaunchScreen.storyboard +++ b/MarsWater/MarsWater/Base.lproj/LaunchScreen.storyboard @@ -1,7 +1,7 @@ - + - + diff --git a/MarsWater/MarsWater/Base.lproj/Main.storyboard b/MarsWater/MarsWater/Base.lproj/Main.storyboard index b128c95..60e1b82 100644 --- a/MarsWater/MarsWater/Base.lproj/Main.storyboard +++ b/MarsWater/MarsWater/Base.lproj/Main.storyboard @@ -43,7 +43,7 @@ - + @@ -73,12 +73,28 @@ - + + + + + @@ -254,10 +270,10 @@ - + - + @@ -271,14 +287,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MarsWater/MarsWater/ListsTableViewController.m b/MarsWater/MarsWater/ListsTableViewController.m index e2aeecf..caa73ca 100644 --- a/MarsWater/MarsWater/ListsTableViewController.m +++ b/MarsWater/MarsWater/ListsTableViewController.m @@ -75,11 +75,14 @@ - (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id) - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - TaskListTableViewController *vc = [segue destinationViewController]; - - NSIndexPath *indexPath = [self.tableView indexPathForCell:sender]; - - vc.task = self.fetchedResultsController.fetchedObjects[indexPath.row]; + if ([[segue identifier] isEqualToString:@"Tasks"]) { + + TaskListTableViewController *vc = [segue destinationViewController]; + + NSIndexPath *indexPath = [self.tableView indexPathForCell:sender]; + + vc.task = self.fetchedResultsController.fetchedObjects[indexPath.row]; + } } diff --git a/MarsWater/MarsWater/TaskCreationViewController.h b/MarsWater/MarsWater/TaskCreationViewController.h new file mode 100644 index 0000000..d45cb07 --- /dev/null +++ b/MarsWater/MarsWater/TaskCreationViewController.h @@ -0,0 +1,13 @@ +// +// TaskCreationViewController.h +// MarsWater +// +// Created by Natalia Estrella on 10/9/15. +// Copyright © 2015 Michael Kavouras. All rights reserved. +// + +#import + +@interface TaskCreationViewController : UIViewController + +@end diff --git a/MarsWater/MarsWater/TaskCreationViewController.m b/MarsWater/MarsWater/TaskCreationViewController.m new file mode 100644 index 0000000..95e283f --- /dev/null +++ b/MarsWater/MarsWater/TaskCreationViewController.m @@ -0,0 +1,45 @@ +// +// TaskCreationViewController.m +// MarsWater +// +// Created by Natalia Estrella on 10/9/15. +// Copyright © 2015 Michael Kavouras. All rights reserved. +// + +#import +#import "TaskCreationViewController.h" +#import "AppDelegate.h" +#import "Task.h" + +@interface TaskCreationViewController () +@property (weak, nonatomic) IBOutlet UITextField *descriptionField; +@property (weak, nonatomic) IBOutlet UIDatePicker *datePicker; + +@end + +@implementation TaskCreationViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view. +} + + + +- (IBAction)createTapped:(id)sender { + + AppDelegate *delegate = [UIApplication sharedApplication].delegate; + Task *task = [NSEntityDescription insertNewObjectForEntityForName:@"Task" inManagedObjectContext:delegate.managedObjectContext]; + + task.taskDescription = self.descriptionField.text; + task.createdAt = [NSDate date]; + task.updatedAt = [NSDate date]; + task.dueAt = self.datePicker.date; + task.priority = @(1); + + [delegate.managedObjectContext save:nil]; + + [self.navigationController popViewControllerAnimated:YES]; +} + +@end diff --git a/MarsWater/MarsWater/TaskListTableViewController.m b/MarsWater/MarsWater/TaskListTableViewController.m index 2f109bf..0480ca2 100644 --- a/MarsWater/MarsWater/TaskListTableViewController.m +++ b/MarsWater/MarsWater/TaskListTableViewController.m @@ -7,94 +7,79 @@ // #import "TaskListTableViewController.h" +#import "ListsTableViewController.h" +#import "AppDelegate.h" +#import "Task.h" +#import "TaskListTableViewController.h" + +@interface TaskListTableViewController () -@interface TaskListTableViewController () +@property (nonatomic) NSFetchedResultsController *fetchedResultsController; @end @implementation TaskListTableViewController + - (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; + AppDelegate *delegate = [UIApplication sharedApplication].delegate; + + // 1) create an instance of NSFetchRequest with an entity name + NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:@"Task"]; + + + // 2) create a sort descriptor + NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"createdAt" ascending:NO]; + + // 3) set the sortDescriptors on the fetchRequest + fetchRequest.sortDescriptors = @[sort]; + + // 4) create a fetchedResultsController with a fetchRequest and a managedObjectContext, + self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:delegate.managedObjectContext sectionNameKeyPath:nil cacheName:nil]; + + self.fetchedResultsController.delegate = self; + + [self.fetchedResultsController performFetch:nil]; + + [self.tableView reloadData]; } - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { -#warning Incomplete implementation, return the number of sections - return 0; + return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { -#warning Incomplete implementation, return the number of rows - return 0; + return self.fetchedResultsController.fetchedObjects.count; } -/* - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath]; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: @"TaskCellIdentifier" forIndexPath:indexPath]; + + NSDateFormatter *dateFormatter = [NSDateFormatter new]; + dateFormatter.timeStyle = kCFDateFormatterMediumStyle; - // Configure the cell... + Task *task = self.fetchedResultsController.fetchedObjects[indexPath.row]; + cell.textLabel.text = task.taskDescription; + cell.detailTextLabel.text = [NSString stringWithFormat:@"Due at %@", [dateFormatter stringFromDate:task.dueAt]]; 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 - } +- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath { + + [self.tableView reloadData]; } -*/ -/* -// Override to support rearranging the table view. -- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { -} -*/ +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ -/* -// 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