Skip to content

Chapter 5: Coding Error Under "Creating a Cocoa Touch Class" #3

@ccocchiaro

Description

@ccocchiaro

In Chapter 5 (page 97 of the Extreme Mobile PDF) under "Creating a Cocoa Touch Class", the code sample should reference the correct UserDefault (e.g. trackCount). The downloaded code itself is correct, only the book contains the oversight:

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
        
    var trackCount = 1
        
    if let bundle = Bundle(identifier:"com.gw.RecordingStudioFW"),
            let path = bundle.path(forResource: "RecordingStudio", ofType: "plist"),
            let plistDict = NSDictionary(contentsOfFile: path),
            let tracks = plistDict.object(forKey: "trackCount") as? Int {
        trackCount = tracks
    }

    if let features = UserDefaults.standard.object(forKey: "iaps") as? [String: Any],
           let tracks = features["trackCount"] as? Int {
        trackCount = tracks
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions