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