Friday, September 21, 2018

Itinerary App - Part 18 - Swipe to Edit Table View Row (iOS, Xcode 10, S...

In the last video you learned how to swipe to delete a table view row and present the user with an alert. In this video you will learn about swiping right and showing and edit action. When tapped we will present the user with our popup with the trip title and image loaded.



You're also going to learn some other things such as new Xcode 10 and Swift 4.2 features, calling a segue in code, problems with named colors and image assets, a tool to find matching colors to expand your color theme and much more!







-- CODE UPDATES --

There are some things I forgot to cover while teaching that are important.



1. We want to reset the tripIndexToEdit in our TripsViewController after the popup closes. If we don't set that variable back to nil then the popup will always thing you want to edit. We want to do this in the prepareForSegue, in the popup's doneSaving action:



override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

    if segue.identifier == "toAddTripSegue" {

        let popup = segue.destination as! AddTripViewController

        popup.tripIndexToEdit = self.tripIndexToEdit

        popup.doneSaving = { [weak self] in

            self?.tableView.reloadData()

            self?.tripIndexToEdit = nil

        }

    }

}



2. I forgot to change the popup's title (titleLabel) when we are editing a trip! Here is the code we want in the popup's viewDidLoad:



if let index = tripIndexToEdit {

    let trip = Data.tripModels[index]

    tripTextField.text = trip.title

    imageView.image = trip.image

    titleLabel.text = "Edit Trip"

}

Wednesday, September 12, 2018

Itinerary App - Part 17 - Swipe To Delete Table View Row (iOS, Xcode 9, ...

In this video you will learn the new way to swipe to delete (since iOS 11). When swiping to delete a table view row we will be presenting the user with an alert confirmation too. You will learn how to configure the button that is exposed by swiping, such as setting the text, icon and background color and the action to perform after tapping the button exposed by swiping.

In-Depth Info on configuring swipe actions:
https://youtu.be/RSxfGGdA8QE



SwiftUI Search & Filter with Combine - Part 3 (iOS, Xcode 13, SwiftUI, 2...

In part 3 of the Searchable video series, I show you how to use Combine in #SwiftUI for the search and filter logic connected to the searcha...