concept child in category ios

appears as: children
iOS Development with Swift

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

  • Give the Book structure an initializer that generates a new Book object based on an XML node. Unwrap the XML node text values, and instantiate a new Book. This code is similar to the property list code in the previous section.
    init?(book: XMLNode) {                                1
       guard let title = book[Key.title]?.text,           2
           let author = book[Key.author]?.text,           2
           let ratingString = book[Key.rating]?.text,     2
           let rating = Double(ratingString),             23
           let isbn = book[Key.isbn]?.text,               2
           let notes = book[Key.notes]?.text              2
           else {return nil}
       self.init(title: title,                            4
                 author: author,                          4
                 rating: rating,                          4
                 isbn: isbn,                              4
                 notes: notes                             4
                 )
    }
    • 1 Failable initializer
    • 2 Unwraps dictionary properties
    • 3 Casts rating to Double
    • 4 Calls designated initializer
    The BooksManager can now retrieve the XML structure from file using the XML class. The root element of the XML will contain a series of children nodes that represent book data.
  • Apps intended for kids do have specific requirements, such as requiring a privacy policy and potentially requiring a “parental gate,” a task at an adult level that would prevent children from accessing parts of the app not intended for children, such as in-app purchases.