2019-02-20

    MobileLab: TableView assignment

    👉 Source code is at my GitHub repo

    Building iOS app (Swift) is a totally different experience from web development (JS). The most challenging part for me is the complicated and confusing class inheritance. This week's assignment of building app with TableView provides a great opportunity to get more familiar of the relationships between classes. Still get tons of questions though.


    Develop Process

    sketch of basic interface and struct of data sketch of basic interface and struct of data

    I intended to build a more complex interface, but get stuck by lots of problems along the way. During the development process, I focus on building a most viable product with only text fields and pickers as data source to send from modal view to table view.

    0.5 version 0.5 version with emoji instead of real image

    After the basic functions were built, I tried to figure out how to store/fetch image using FileManager and swipe gesture on table cells.


    Questions

    1. What's labeled Identifier in Atrributes inspector?
    2. UIBarButtonItem connect to exit v.s. IBAction to dismiss current scene
    3. instantiateViewController and board flow connection?
    4. How to set nav bar as footer? Or additional footer instead?
    5. What's weak self?
    6. textFieldShouldReturn not working, had to use IBAction instead. I Have to adopt UITextFieldDelegate protocol on ViewController class to make it work in my code. Why doesn't example code need one?
    7. How to set relative constraints? And how to add padding to textfields? relative-constraints.png

    Learning doc

    Codable protocol

    UITableView

    • segue: transition between scenes
    • unwind segue: implementing backward navigation
    • navigation controller: manages transitions backward and forward through a series of view controllers.
      • table view controller is the navigation controller's root view controller
      • entry point is set to navigation controller because it's container for table view controller
      • editor -> Embed in -> navigation controller
    • type casting in TableViewController to TableViewCell type casting
    • didSaveElement declaration location (it's a closure). Taking elementArray to ActionViewController, closure of the array data. didSaveElementFunction.png
    • Delegate: The delegating object (textField for example) keeps a reference to the other object (the delegate). The delegating object sends message to the delegate at appropriate time.
    • Coadable only works for specific types, not including UIImage codable-uiimage.png
    • Swipe gesture on cell: iOS 11: Swipe left/right in UITableViewCell – Developers Log
    • Handle empty tableView: Handle Empty TableView in Swift 4 & iOS 11 – Taha Sönmez – Medium

    FileManager (image management)