diff --git a/MarsWater/MarsWater.xcodeproj/project.pbxproj b/MarsWater/MarsWater.xcodeproj/project.pbxproj index a2f82e3..49484c6 100644 --- a/MarsWater/MarsWater.xcodeproj/project.pbxproj +++ b/MarsWater/MarsWater.xcodeproj/project.pbxproj @@ -7,9 +7,11 @@ objects = { /* Begin PBXBuildFile section */ + 3D06E65D1BC4BA4400FBEEC5 /* TaskCreationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D06E65C1BC4BA4400FBEEC5 /* TaskCreationViewController.m */; }; + 3D0D8A521BC7FDCD00A76706 /* ListCreationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D0D8A511BC7FDCD00A76706 /* ListCreationViewController.m */; }; + 3D0D8A551BC8096E00A76706 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3D0D8A531BC8096E00A76706 /* Main.storyboard */; }; 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 */; }; @@ -22,11 +24,15 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 3D06E65B1BC4BA4400FBEEC5 /* TaskCreationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TaskCreationViewController.h; sourceTree = ""; }; + 3D06E65C1BC4BA4400FBEEC5 /* TaskCreationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TaskCreationViewController.m; sourceTree = ""; }; + 3D0D8A501BC7FDCD00A76706 /* ListCreationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ListCreationViewController.h; sourceTree = ""; }; + 3D0D8A511BC7FDCD00A76706 /* ListCreationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ListCreationViewController.m; sourceTree = ""; }; + 3D0D8A541BC8096E00A76706 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; 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 = ""; }; 8DA86CAB1BC1AE57006C50BC /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 8DA86CB11BC1AE57006C50BC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 8DA86CB41BC1AE57006C50BC /* MarsWater.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MarsWater.xcdatamodel; sourceTree = ""; }; 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 = ""; }; @@ -75,6 +81,9 @@ 8DA86CA61BC1AE57006C50BC /* MarsWater */ = { isa = PBXGroup; children = ( + 3D0D8A531BC8096E00A76706 /* Main.storyboard */, + 3D0D8A501BC7FDCD00A76706 /* ListCreationViewController.h */, + 3D0D8A511BC7FDCD00A76706 /* ListCreationViewController.m */, 8DA86CD11BC1B329006C50BC /* Model */, 8DA86CAA1BC1AE57006C50BC /* AppDelegate.h */, 8DA86CAB1BC1AE57006C50BC /* AppDelegate.m */, @@ -82,12 +91,13 @@ 8DA86CD31BC1B8E4006C50BC /* ListsTableViewController.m */, 8DA86CD51BC1B904006C50BC /* ListCreationTableViewController.h */, 8DA86CD61BC1B904006C50BC /* ListCreationTableViewController.m */, - 8DA86CB01BC1AE57006C50BC /* Main.storyboard */, 8DA86CB61BC1AE57006C50BC /* Assets.xcassets */, 8DA86CB81BC1AE57006C50BC /* LaunchScreen.storyboard */, 8DA86CBB1BC1AE57006C50BC /* Info.plist */, 8DA86CB31BC1AE57006C50BC /* MarsWater.xcdatamodeld */, 8DA86CA71BC1AE57006C50BC /* Supporting Files */, + 3D06E65B1BC4BA4400FBEEC5 /* TaskCreationViewController.h */, + 3D06E65C1BC4BA4400FBEEC5 /* TaskCreationViewController.m */, ); path = MarsWater; sourceTree = ""; @@ -146,6 +156,7 @@ TargetAttributes = { 8DA86CA31BC1AE57006C50BC = { CreatedOnToolsVersion = 7.0.1; + DevelopmentTeam = 3358H79N3F; }; }; }; @@ -172,9 +183,9 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 3D0D8A551BC8096E00A76706 /* Main.storyboard in Resources */, 8DA86CBA1BC1AE57006C50BC /* LaunchScreen.storyboard in Resources */, 8DA86CB71BC1AE57006C50BC /* Assets.xcassets in Resources */, - 8DA86CB21BC1AE57006C50BC /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -186,9 +197,11 @@ buildActionMask = 2147483647; files = ( 8DA86CB51BC1AE57006C50BC /* MarsWater.xcdatamodeld in Sources */, + 3D0D8A521BC7FDCD00A76706 /* ListCreationViewController.m in Sources */, 8DA86CAC1BC1AE57006C50BC /* AppDelegate.m in Sources */, 8DB2F6EA1BC1E75500E58E65 /* Task+CoreDataProperties.m in Sources */, 8DA86CD41BC1B8E4006C50BC /* ListsTableViewController.m in Sources */, + 3D06E65D1BC4BA4400FBEEC5 /* TaskCreationViewController.m in Sources */, 8DB2F6E71BC1E75500E58E65 /* List.m in Sources */, 8DB2F6E91BC1E75500E58E65 /* Task.m in Sources */, 8DA86CD71BC1B904006C50BC /* ListCreationTableViewController.m in Sources */, @@ -200,10 +213,10 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ - 8DA86CB01BC1AE57006C50BC /* Main.storyboard */ = { + 3D0D8A531BC8096E00A76706 /* Main.storyboard */ = { isa = PBXVariantGroup; children = ( - 8DA86CB11BC1AE57006C50BC /* Base */, + 3D0D8A541BC8096E00A76706 /* Base */, ); name = Main.storyboard; sourceTree = ""; @@ -303,10 +316,14 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; INFOPLIST_FILE = MarsWater/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.MarsWater; + PRODUCT_BUNDLE_IDENTIFIER = com.accesscode.zovfreullia.MarsWater; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; }; name = Debug; }; @@ -314,10 +331,14 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; INFOPLIST_FILE = MarsWater/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.1; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.mikekavouras.MarsWater; + PRODUCT_BUNDLE_IDENTIFIER = com.accesscode.zovfreullia.MarsWater; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; }; name = Release; }; diff --git a/MarsWater/MarsWater/Assets.xcassets/Contents.json b/MarsWater/MarsWater/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/MarsWater/MarsWater/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/MarsWater/MarsWater/Assets.xcassets/TronGlow7.imageset/Contents.json b/MarsWater/MarsWater/Assets.xcassets/TronGlow7.imageset/Contents.json new file mode 100644 index 0000000..57d4cf6 --- /dev/null +++ b/MarsWater/MarsWater/Assets.xcassets/TronGlow7.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "TronGlow7.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/MarsWater/MarsWater/Assets.xcassets/TronGlow7.imageset/TronGlow7.png b/MarsWater/MarsWater/Assets.xcassets/TronGlow7.imageset/TronGlow7.png new file mode 100644 index 0000000..4cec0cd Binary files /dev/null and b/MarsWater/MarsWater/Assets.xcassets/TronGlow7.imageset/TronGlow7.png differ diff --git a/MarsWater/MarsWater/Assets.xcassets/bluesci.imageset/Contents.json b/MarsWater/MarsWater/Assets.xcassets/bluesci.imageset/Contents.json new file mode 100644 index 0000000..f2ac36d --- /dev/null +++ b/MarsWater/MarsWater/Assets.xcassets/bluesci.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "bluesci.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/MarsWater/MarsWater/Assets.xcassets/bluesci.imageset/bluesci.png b/MarsWater/MarsWater/Assets.xcassets/bluesci.imageset/bluesci.png new file mode 100644 index 0000000..39352bd Binary files /dev/null and b/MarsWater/MarsWater/Assets.xcassets/bluesci.imageset/bluesci.png differ diff --git a/MarsWater/MarsWater/Assets.xcassets/denim1.imageset/Contents.json b/MarsWater/MarsWater/Assets.xcassets/denim1.imageset/Contents.json new file mode 100644 index 0000000..a7b00dc --- /dev/null +++ b/MarsWater/MarsWater/Assets.xcassets/denim1.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "denim1.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/MarsWater/MarsWater/Assets.xcassets/denim1.imageset/denim1.jpg b/MarsWater/MarsWater/Assets.xcassets/denim1.imageset/denim1.jpg new file mode 100644 index 0000000..ea0f6d9 Binary files /dev/null and b/MarsWater/MarsWater/Assets.xcassets/denim1.imageset/denim1.jpg differ diff --git a/MarsWater/MarsWater/Assets.xcassets/geometrybg.imageset/Contents.json b/MarsWater/MarsWater/Assets.xcassets/geometrybg.imageset/Contents.json new file mode 100644 index 0000000..2b4064a --- /dev/null +++ b/MarsWater/MarsWater/Assets.xcassets/geometrybg.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "geometrybg.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/MarsWater/MarsWater/Assets.xcassets/geometrybg.imageset/geometrybg.jpg b/MarsWater/MarsWater/Assets.xcassets/geometrybg.imageset/geometrybg.jpg new file mode 100644 index 0000000..194e98e Binary files /dev/null and b/MarsWater/MarsWater/Assets.xcassets/geometrybg.imageset/geometrybg.jpg differ diff --git a/MarsWater/MarsWater/Assets.xcassets/purple.imageset/Contents.json b/MarsWater/MarsWater/Assets.xcassets/purple.imageset/Contents.json new file mode 100644 index 0000000..cd1e70e --- /dev/null +++ b/MarsWater/MarsWater/Assets.xcassets/purple.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "purple.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/MarsWater/MarsWater/Assets.xcassets/purple.imageset/purple.jpg b/MarsWater/MarsWater/Assets.xcassets/purple.imageset/purple.jpg new file mode 100644 index 0000000..560d74e Binary files /dev/null and b/MarsWater/MarsWater/Assets.xcassets/purple.imageset/purple.jpg differ diff --git a/MarsWater/MarsWater/Assets.xcassets/scifi.imageset/Contents.json b/MarsWater/MarsWater/Assets.xcassets/scifi.imageset/Contents.json new file mode 100644 index 0000000..2df9c21 --- /dev/null +++ b/MarsWater/MarsWater/Assets.xcassets/scifi.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "scifi.jpg", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/MarsWater/MarsWater/Assets.xcassets/scifi.imageset/scifi.jpg b/MarsWater/MarsWater/Assets.xcassets/scifi.imageset/scifi.jpg new file mode 100644 index 0000000..14347ad Binary files /dev/null and b/MarsWater/MarsWater/Assets.xcassets/scifi.imageset/scifi.jpg differ diff --git a/MarsWater/MarsWater/Assets.xcassets/terminal.imageset/Contents.json b/MarsWater/MarsWater/Assets.xcassets/terminal.imageset/Contents.json new file mode 100644 index 0000000..71ca72e --- /dev/null +++ b/MarsWater/MarsWater/Assets.xcassets/terminal.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "terminal.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/MarsWater/MarsWater/Assets.xcassets/terminal.imageset/terminal.png b/MarsWater/MarsWater/Assets.xcassets/terminal.imageset/terminal.png new file mode 100644 index 0000000..21a2308 Binary files /dev/null and b/MarsWater/MarsWater/Assets.xcassets/terminal.imageset/terminal.png differ diff --git a/MarsWater/MarsWater/Assets.xcassets/whitebg.imageset/Contents.json b/MarsWater/MarsWater/Assets.xcassets/whitebg.imageset/Contents.json new file mode 100644 index 0000000..671a83f --- /dev/null +++ b/MarsWater/MarsWater/Assets.xcassets/whitebg.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "whitebg.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/MarsWater/MarsWater/Assets.xcassets/whitebg.imageset/whitebg.png b/MarsWater/MarsWater/Assets.xcassets/whitebg.imageset/whitebg.png new file mode 100644 index 0000000..b689917 Binary files /dev/null and b/MarsWater/MarsWater/Assets.xcassets/whitebg.imageset/whitebg.png differ diff --git a/MarsWater/MarsWater/Base.lproj/LaunchScreen.storyboard b/MarsWater/MarsWater/Base.lproj/LaunchScreen.storyboard index 2e721e1..9105557 100644 --- a/MarsWater/MarsWater/Base.lproj/LaunchScreen.storyboard +++ b/MarsWater/MarsWater/Base.lproj/LaunchScreen.storyboard @@ -1,7 +1,8 @@ - + - + + diff --git a/MarsWater/MarsWater/Base.lproj/Main.storyboard b/MarsWater/MarsWater/Base.lproj/Main.storyboard index 13ead89..cd34722 100644 --- a/MarsWater/MarsWater/Base.lproj/Main.storyboard +++ b/MarsWater/MarsWater/Base.lproj/Main.storyboard @@ -1,46 +1,51 @@ - + - + + + - + - - + + - + + + + @@ -70,12 +75,120 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -85,12 +198,12 @@ - + - + @@ -100,7 +213,7 @@ - + @@ -123,7 +236,7 @@ - + @@ -213,7 +326,220 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -233,4 +559,10 @@ + + + + + + diff --git a/MarsWater/MarsWater/List+CoreDataProperties.h b/MarsWater/MarsWater/List+CoreDataProperties.h index 9ce8d06..ccbccbd 100644 --- a/MarsWater/MarsWater/List+CoreDataProperties.h +++ b/MarsWater/MarsWater/List+CoreDataProperties.h @@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nullable, nonatomic, retain) NSString *title; @property (nullable, nonatomic, retain) NSDate *createdAt; @property (nullable, nonatomic, retain) id color; -@property (nullable, nonatomic, retain) NSArray *task; +@property (nullable, nonatomic, retain) NSOrderedSet *task; @end diff --git a/MarsWater/MarsWater/ListCreationViewController.h b/MarsWater/MarsWater/ListCreationViewController.h new file mode 100644 index 0000000..79321b5 --- /dev/null +++ b/MarsWater/MarsWater/ListCreationViewController.h @@ -0,0 +1,13 @@ +// +// ListCreationViewController.h +// MarsWater +// +// Created by Fatima Zenine Villanueva on 10/9/15. +// Copyright © 2015 Michael Kavouras. All rights reserved. +// + +#import + +@interface ListCreationViewController : UIViewController + +@end diff --git a/MarsWater/MarsWater/ListCreationViewController.m b/MarsWater/MarsWater/ListCreationViewController.m new file mode 100644 index 0000000..cd80e11 --- /dev/null +++ b/MarsWater/MarsWater/ListCreationViewController.m @@ -0,0 +1,69 @@ +// +// ListCreationViewController.m +// MarsWater +// +// Created by Fatima Zenine Villanueva on 10/9/15. +// Copyright © 2015 Michael Kavouras. All rights reserved. +// + +#import +#import "AppDelegate.h" +#import "List.h" +#import "ListCreationViewController.h" + +@interface ListCreationViewController () + +@property (weak, nonatomic) IBOutlet UITextField *listTextField; + +@property (nonatomic) List *list; + +@end + +@implementation ListCreationViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + AppDelegate *delegate = [UIApplication sharedApplication].delegate; + + self.list = [NSEntityDescription insertNewObjectForEntityForName:@"List" inManagedObjectContext:delegate.managedObjectContext]; +} +- (IBAction)cancel:(UIBarButtonItem *)sender { + + self.list.color = nil; + self.list.title = nil; + [self dismissViewControllerAnimated:YES completion:nil]; +} + +- (IBAction)marsWaterColorButton:(UIButton *)sender { + self.list.color = sender.backgroundColor; +} + +- (IBAction)save:(UIBarButtonItem *)sender { + + self.list.title = self.listTextField.text; + self.list.createdAt = [NSDate date]; + + AppDelegate *delegate = [UIApplication sharedApplication].delegate; + [delegate.managedObjectContext save:nil]; + + [self dismissViewControllerAnimated:YES completion:nil]; + +} + + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; +} + +/* + #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/MarsWater/MarsWater/ListsTableViewController.m b/MarsWater/MarsWater/ListsTableViewController.m index 8a2659c..03e9cce 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 "TaskCreationViewController.h" @interface ListsTableViewController () @@ -64,13 +65,57 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N cell.textLabel.text = list.title; cell.detailTextLabel.text = [list.createdAt description]; + if (list.task.count >= 1){ + cell.detailTextLabel.text = [NSString stringWithFormat: @"Tasks: %lu " ,list.task.count]; + } return cell; } - (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath { - + [self.tableView reloadData]; } +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + + // Make sure your segue name in storyboard is the same as this line + if ([[segue identifier] isEqualToString:@"TaskCreation"]) + { + NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; + TaskCreationViewController *vc = segue.destinationViewController; + List *list = self.fetchedResultsController.fetchedObjects[indexPath.row]; + vc.list = list; + + NSLog(@"segue list %@", vc.list); + } +} + + +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath +{ + if(editingStyle == UITableViewCellEditingStyleDelete) + { + NSManagedObjectContext *context = + [self.fetchedResultsController managedObjectContext]; + + NSManagedObject *objectToBeDeleted = + [self.fetchedResultsController objectAtIndexPath:indexPath]; + + [context deleteObject:objectToBeDeleted]; + + AppDelegate *delegate = [UIApplication sharedApplication].delegate; + + [delegate.managedObjectContext save:nil]; + + NSError *error = nil; + if (![context save:&error]) + { + NSLog(@"Error deleting movie, %@", [error userInfo]); + } + + [self.tableView reloadData]; + } +} + @end diff --git a/MarsWater/MarsWater/MarsWater.xcdatamodeld/MarsWater.xcdatamodel/contents b/MarsWater/MarsWater/MarsWater.xcdatamodeld/MarsWater.xcdatamodel/contents index 116441d..59cc3ea 100644 --- a/MarsWater/MarsWater/MarsWater.xcdatamodeld/MarsWater.xcdatamodel/contents +++ b/MarsWater/MarsWater/MarsWater.xcdatamodeld/MarsWater.xcdatamodel/contents @@ -1,5 +1,5 @@ - + @@ -16,7 +16,7 @@ - - + + \ No newline at end of file diff --git a/MarsWater/MarsWater/Task+CoreDataProperties.h b/MarsWater/MarsWater/Task+CoreDataProperties.h index 2cc11d7..7d7b5a9 100644 --- a/MarsWater/MarsWater/Task+CoreDataProperties.h +++ b/MarsWater/MarsWater/Task+CoreDataProperties.h @@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nullable, nonatomic, retain) NSDate *updatedAt; @property (nullable, nonatomic, retain) NSNumber *priority; @property (nullable, nonatomic, retain) NSDate *completedAt; -@property (nullable, nonatomic, retain) List *list; +@property (nullable, nonatomic, retain) NSManagedObject *list; @end diff --git a/MarsWater/MarsWater/TaskCreationViewController.h b/MarsWater/MarsWater/TaskCreationViewController.h new file mode 100644 index 0000000..ec2bca5 --- /dev/null +++ b/MarsWater/MarsWater/TaskCreationViewController.h @@ -0,0 +1,17 @@ +// +// TaskCreationViewController.h +// MarsWater +// +// Created by Fatima Zenine Villanueva on 10/6/15. +// Copyright © 2015 Michael Kavouras. All rights reserved. +// + +#import +#import "List.h" + +@interface TaskCreationViewController : UIViewController + +@property (nonatomic) List *list; + + +@end diff --git a/MarsWater/MarsWater/TaskCreationViewController.m b/MarsWater/MarsWater/TaskCreationViewController.m new file mode 100644 index 0000000..0e3bdbf --- /dev/null +++ b/MarsWater/MarsWater/TaskCreationViewController.m @@ -0,0 +1,117 @@ +// +// TaskCreationViewController.m +// MarsWater +// +// Created by Fatima Zenine Villanueva on 10/6/15. +// Copyright © 2015 Michael Kavouras. All rights reserved. +// + +#import "TaskCreationViewController.h" +#import "Task.h" +#import "List.h" +#import "AppDelegate.h" + +@interface TaskCreationViewController () + +@property (nonatomic) NSFetchedResultsController *fetchedResultsController; + +@property (weak, nonatomic) IBOutlet UITableView *tableView; +@property (weak, nonatomic) IBOutlet UITextField *taskTextField; + +@property (nonatomic) NSMutableOrderedSet *testSet; + + +@property (nonatomic) Task *task; + +@end + +@implementation TaskCreationViewController + +- (void)viewDidLoad { + self.tableView.delegate = self; + self.tableView.dataSource = self; + self.edgesForExtendedLayout = UIRectEdgeNone; + + AppDelegate *delegate = [UIApplication sharedApplication].delegate; + + self.task = [NSEntityDescription insertNewObjectForEntityForName:@"Task" inManagedObjectContext:delegate.managedObjectContext]; + + self.testSet = [[NSMutableOrderedSet alloc]init]; + + + // 1) create an instance of NSFetchRequest with an entity name + NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:@"List"]; + + + // 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]; + + + [super viewDidLoad]; +} + + +- (IBAction)addingNewTask:(UIButton *)sender +{ + AppDelegate *delegate = [UIApplication sharedApplication].delegate; + + self.task = [NSEntityDescription insertNewObjectForEntityForName:@"Task" inManagedObjectContext:delegate.managedObjectContext]; + + self.task.taskDescription = self.taskTextField.text; + + self.task.createdAt = [NSDate date]; + + self.testSet = self.list.task.mutableCopy; + + [self.testSet addObject:self.task]; + + self.list.task = self.testSet; + + [delegate.managedObjectContext save:nil]; + + [self.tableView reloadData]; + +} + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return self.list.task.count; +} + + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: @"TaskIdentifier" forIndexPath:indexPath]; + + Task *cellTask = self.list.task[indexPath.row]; + + cell.textLabel.text = cellTask.taskDescription; + + return cell; +} + +- (IBAction)doneWithTasks:(UIBarButtonItem *)sender { + + [self.navigationController popToRootViewControllerAnimated:YES]; +} + +- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath { + + [self.tableView reloadData]; +} + + + +@end