This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print(String(data: try! JSONSerialization.data(withJSONObject: json, options: .prettyPrinted), encoding: .utf8 )!) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
guard let path = Bundle.main.path(forResource: "ScheduleMock", ofType: "json") else { | |
return | |
} | |
do { | |
let data = try Data(contentsOf: URL(fileURLWithPath: path), options: .mappedIfSafe) | |
let schedule = try Mapper<TakeawayScheduleModel>().map(JSONString: data.string) | |
print(schedule.title) | |
} catch { | |
print(error.localizedDescription) | |
assertionFailure() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Chapter 1: Introducing Auto Layout | |
// Chapter 2: Construct Auto Layout with the Interface Builder | |
// 1 | |
override func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath) { | |
view.addSubview(contactPreviewView) | |
contactPreviewView.translatesAutoresizingMaskIntoConstraints = false | |
NSLayoutConstraint.activate([ // this line of code more performant than activating each constraint individually | |
contactPreviewView.widthAnchor.constraint(equalToConstant: 150), | |
contactPreviewView.heightAnchor.constraint(equalToConstant: 150), |
OlderNewer