Frank#22
Open
fmartin0212 wants to merge 3 commits into
Open
Conversation
ETLanza
reviewed
Mar 15, 2019
| * implement the NSFetchedResultsControllerDelegate to observe changes in Core Data information and update the display accordingly | ||
|
|
||
| ### Set up | ||
| Add the complete and incomplete images to your Assets folder. Images can be found ~~~~~~~~~~~~~~here~~~~~~~~~~~~~ |
|
|
||
| 1. A `name` of type `String` | ||
| 2. An optional `notes` of type `String` | ||
| 3. An optiopnal `due` of type `Date` |
| 1. The `Task` object to be updated | ||
| 2. A `name` of type `String` | ||
| 3. An optional `notes` of type `String` | ||
| 4. An optiopnal `due` of type `Date` |
|
|
||
| ##### Switch Table View Cell | ||
|
|
||
| We can successfully create and update new tasks; however, we still need to be able to display them in the our table view, and provide the functionality for the tasks to be completed. |
kpfister
reviewed
Apr 12, 2019
|
|
||
| ### Wire up storyboard to code | ||
|
|
||
| Let's shift our focus to the UI of the app. Create a new subclass file of UITableViewCell named `SwitchTableViewCell`. Add one variable in the class named `task` of type `Task`. This will be used as our landing pad. We will revisit this cell later. |
Contributor
There was a problem hiding this comment.
I really like this transition
kpfister
reviewed
Apr 12, 2019
|
|
||
| // Soure of truth | ||
| var tasks: [Task] = [] | ||
| } |
Contributor
There was a problem hiding this comment.
Let's remove this hint. They should know to do this by now
kpfister
reviewed
Apr 12, 2019
| ``` | ||
| func update(_ task: Task, _ name: String, notes: String?, due: Date?) { | ||
|
|
||
| // Set the tasks's properties to the parameters that were passed in |
Contributor
There was a problem hiding this comment.
Lets remove this Hint too
kpfister
reviewed
Apr 12, 2019
| Let's handle when a user taps on an existing task. Add an optional 'landing pad' of type `Task` to your `TaskDetailTableViewController` file. | ||
|
|
||
| ``` | ||
| // Landing pad |
kpfister
reviewed
Apr 12, 2019
| guard let destinationVC = segue.destination as? TaskDetailTableViewController, | ||
|
|
||
| // Grab the indexPath of the row that was selected | ||
| let indexPath = tableView.indexPathForSelectedRow |
kpfister
reviewed
Apr 12, 2019
| 1. Drag outlets from your storyboard's view controller into your swift file. Make sure you include an outlet for the date picker. | ||
| 2. Add an `updateViews` function to your class that 1) unwraps your `Task` landing pad and 2) updates all of the UI elements on task detail view using the unwrapped landing pad's properties. Add a `didSet` to your `Task` landing pad and call both `loadViewIfNeeded` and `updateViews` in that order. `loadViewIfNeeded` loads the view if it hasn't already been loaded; if this function is not called, your app will crash when you get to the detail view. | ||
|
|
||
| Next, let's tackle saving/updating. |
Contributor
There was a problem hiding this comment.
Can we make this transition a bit larger font - maybe like a subtitle
kpfister
reviewed
Apr 12, 2019
|
|
||
| 1. Drag out an `IBAction` for your `saveBarButtonItem`. | ||
| 2. In `viewDidLoad`, assign the `dueTextField's` `inputView` to your date picker. | ||
| 3. In your `saveButtonTapped` function, safely unwrap the `nameTextField's` text and either a) create a new instance of `Task`, or b) update an existing task. Remember that `due` and `notes` are both optional. Also note that the data for `due` should come from your date picker, not the `dueTextField` itself. Finally, pop the view controller off the navigation stack. This should happen regardless of whether an update or creation is occuring. |
Contributor
There was a problem hiding this comment.
In your saveButtonTapped function, safely unwrap the nameTextField's text and using the value of Task handle creation and updating accordingly.
kpfister
reviewed
Apr 12, 2019
| if let task = task { | ||
|
|
||
| // Update the task | ||
| TaskController.shared.update(task, name: name, notes: notesTextView.text, due: datePicker.date) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.