Skip to content

Frank#22

Open
fmartin0212 wants to merge 3 commits into
masterfrom
frank
Open

Frank#22
fmartin0212 wants to merge 3 commits into
masterfrom
frank

Conversation

@fmartin0212
Copy link
Copy Markdown
Contributor

No description provided.

* 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~~~~~~~~~~~~~
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing link


1. A `name` of type `String`
2. An optional `notes` of type `String`
3. An optiopnal `due` of type `Date`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An "optional"

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`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"optional"


##### 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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete "the" or "our"


### 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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this transition


// Soure of truth
var tasks: [Task] = []
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this hint. They should know to do this by now

```
func update(_ task: Task, _ name: String, notes: String?, due: Date?) {

// Set the tasks's properties to the parameters that were passed in
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets remove this Hint too

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove Hint

guard let destinationVC = segue.destination as? TaskDetailTableViewController,

// Grab the indexPath of the row that was selected
let indexPath = tableView.indexPathForSelectedRow
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove Hint

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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this transition a bit larger font - maybe like a subtitle


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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In your saveButtonTapped function, safely unwrap the nameTextField's text and using the value of Task handle creation and updating accordingly.

if let task = task {

// Update the task
TaskController.shared.update(task, name: name, notes: notesTextView.text, due: datePicker.date)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove Hint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants