concept opportunity in category ios

appears as: opportunity
iOS Development with Swift

This is an excerpt from Manning's book iOS Development with Swift.

  • Select the title label and open the Attributes Inspector. Notice the grey plus (+) symbol to the left of the font attribute. Selecting the plus symbol gives you the opportunity to add a customized value for a size class.
  • In the viewDidLoad method, the BookViewController should check if the book object exists, and if it does, prefill the fields. If a book object exists, you know that you’re editing rather than creating a book. Take the opportunity to adjust the navigation bar’s title accordingly. Be sure to fill the fields before checking if the Save button should be enabled.
    if let book = book {                                        1
       bookCover.image = book.cover                             2
       titleTextField.text = book.title                         2
       authorTextField.text = book.author                       2
       isbnTextField.text = book.isbn                           2
       notesTextView.text = book.notes                          2
       navigationItem.title = "Edit book"                       3
    }
    saveButton.isEnabled = !titleTextField.text!.isEmpty        4
    • 1 Unwraps book object
    • 2 Prefills form fields with book
    • 3 Changes navigation bar title
    • 4 Disables Save button if no title
  • You’re next given the opportunity to manually manage code signing if you so wish. Most likely, you’ll want Xcode to automatically manage code signing.