Last active
October 9, 2015 22:09
-
-
Save charleshkang/bb6f1451c4a75076c4e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// TaskCreationTableViewController.m | |
// MarsWater | |
// | |
// Created by Charles Kang on 10/8/15. | |
// Copyright © 2015 Michael Kavouras. All rights reserved. | |
// | |
#import "TaskCreationTableViewController.h" | |
#import "Task.h" | |
#import "AppDelegate.h" | |
@interface TaskCreationTableViewController () | |
@property (weak, nonatomic) IBOutlet UITextField *createTaskTextField; | |
@property (nonatomic) Task *task; | |
@property (nonatomic) NSMutableOrderedSet *listTasks; | |
@end | |
@implementation TaskCreationTableViewController | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
self.navigationItem.title = @"Create Tasks"; | |
self.listTasks = self.list.task.mutableCopy; | |
[self setupNavigationBar]; | |
AppDelegate *delegate = [UIApplication sharedApplication].delegate; | |
self.task = [NSEntityDescription insertNewObjectForEntityForName:@"Task" inManagedObjectContext:delegate.managedObjectContext]; | |
} | |
-(void)setupNavigationBar{ | |
self.navigationItem.title = [NSString stringWithFormat:@"Add New Task to %@", self.list.title]; | |
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel)]; | |
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(save)]; | |
self.navigationItem.rightBarButtonItem.tintColor = [UIColor lightGrayColor]; | |
} | |
//-(void)cancel{ | |
// | |
// [self dismissViewControllerAnimated:YES completion:nil]; | |
//} | |
-(void)save{ | |
// set the task properties | |
self.task.taskDescription = self.createTaskTextField.text; | |
if (self.task.createdAt == nil) { | |
self.task.createdAt = [NSDate date]; | |
NSLog(@"%@", self.task); | |
}else { | |
self.task.updatedAt = [NSDate date]; | |
} | |
// update lisk task throwing yellow flag? | |
// self.list.task = self.listTasks; | |
AppDelegate *delegate = [UIApplication sharedApplication].delegate; | |
[delegate.managedObjectContext save:nil]; | |
// [self dismissViewControllerAnimated:YES completion:nil]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment