Hi, I have an error when running the project on Mac Intel while it runs normally on M1.
I tried to delete derived/erase simulator/restart the computer but the project can only build successfully, it cannot start the application.
What can I do to resolve it?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi, I have a problem when trying to parse the JSON which used to work before but it is broken now and I have no idea why it is.
JSON data:
{
"success": true,
"data": {
"email": "example@gmail.com",
"password": "$2b$10$flI1flm1Ptas33z3uBct6.UkhgiRmv/qIzJCVe2PIUycUFIh0BZfW",
"favouriteRestaurants": [],
"favouriteDishes": [],
"_id": "655adf2386348c2be2360852",
"reservations": [],
"createdAt": "2023-11-20T04:22:59.831Z",
"updatedAt": "2023-11-20T04:22:59.831Z",
"__v": 0
}
}
And my model is
struct SignupResponse: Decodable {
let email: String?
let password: String?
let id: String?
private enum CodingKeys: String, CodingKey {
case data
case email
case password
case id = "_id"
}
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let dataContainer = try container.nestedContainer(keyedBy: CodingKeys.self, forKey: .data)
email = try dataContainer.decodeIfPresent(String.self, forKey: .email)
password = try dataContainer.decodeIfPresent(String.self, forKey: .password)
id = try dataContainer.decodeIfPresent(String.self, forKey: .id)
}
I couldn't figure out the reason.
Thank you for your help!