Hello dear friends.
I am new here and I just completed project 10. I can say I understand it good with one exception. When I pick decode my JSON file and try to read it in the alert message in the end it will show me "You ordered 3 vanilla cupcakes"(the default values) even tho I picked Chocolade and 5 of them.
I tried to do a test where I print out in the alert the local values and it works good. It does store properly my entered values but in the step where I encode and decode the data it prints out only the default information. I checked the code several times and its the same as Paul's.
Also I noticed the only diference between me and Paul's code is that in the Order class for me:
required init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let type = try container.decode(Int.self, forKey: .type)
let quantity = try container.decode(Int.self, forKey: .quantity)
let extraFrosting = try container.decode(Bool.self, forKey: .extraFrosting)
let addSprinkles = try container.decode(Bool.self, forKey: .addSprinkles)
let name = try container.decode(String.self, forKey: .name)
let streetAddress = try container.decode(String.self, forKey: .streetAddress)
let city = try container.decode(String.self, forKey: .city)
let zip = try container.decode(String.self, forKey: .zip)
}
It shows a yellow warning for each of the variables in this method. "Initialization of immutable value 'type' was never used; consider replacing with assignment to '_' or removing it".
Cant say I understand this warning. I didnt see it apear in Paul's video even tho our code is the same.
Hope someone can help me. Thank you guys