Skip to content

Instantly share code, notes, and snippets.

@nurtugan
Created June 19, 2020 08:29
Show Gist options
  • Save nurtugan/96497aabe369d89a291779f9fd3eae8c to your computer and use it in GitHub Desktop.
Save nurtugan/96497aabe369d89a291779f9fd3eae8c to your computer and use it in GitHub Desktop.
Example of mocking json with ObjectMapper
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()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment