var delegate:QuizProtocol?
func getQuestions(){
// TODO: Fetch the questions
getLocalJsonFile()
}
func getLocalJsonFile (){
// get bundle path to the json file
let path = Bundle.main.path(forResource: "QuestionData", ofType: "json")
// Double check that the path isn't nil
guard path != nil else {
print("Couldn't find the Json Data file")
return
}
// create URL object from the path
let url = URL(fileURLWithPath: path!)
do {
// Get the data from the url
let data = try Data(contentsOf: url)
// try to decode data into objects
let decoder = JSONDecoder()
let array = try decoder.decode([Question].self, from: data)
// notify the delegate of the parsed objects
delegate?.questionsRetrieved(array)
}
catch {
// Error: Couldn't download the data at that url
}
}
func getRemoteJsonFile(){
}
}
Code line 47
at the let array = try decoder.decode([Question].self, from data
I get error.
Class JSONDecoder requires that Question conform to Decodeable.
Searching for typos.
Note to self
delegate?.questionsRetrieved(array) are not the right colours. In the video the colours of some of the words are different.
Got the questions to display but now the answers are missing. Just says label in the three slots at the bottom. No compiler errors. Still one formatting error - fixed and leading and trailing edges may cause clipping. Searched thru the video where Chris describes this but have not found way to fix this. Deleted all constraints on the label. This brings up other problems.
Searching func tableView for the problem of missing answers.
Tried to change the tag in the other main.storyboard screen objects. Only works if the label tag is set to 1.
Tried the table view, answer cell, content view, view. All came up with label as descriptor. When I changed the label tag to 1 it worked. I thought there would be some kind of dot notation to reference the storyboard screen object but I guess it doesn’t work like that.
Cannot get the command to popup as I type - resultDialog = storyboard.instantiateViewController(identifier: String)
the instantiate does not automatically fill in like it usually does with Xcode.
Deleted the other view controller. Will start again. Last time used uivew to fill in the object. Will use viewcontroller as search. The icons presented look exactly the same.
Went to main project in the document outline - the very top - has the app icon. General settings - Deployment info. Clicked the up/down arrow - changed it to iOS 13.0.
Tried to type the command again. It pops up automatically like it does in the video.
Yeah see I’m thinking about messing with the deployment setting but I’m too chicken to do it lol That’s so weird it actually fixed your missing pop up issue
Trying the Quiz App again. Got the information to load properly. Having problems with layout constraints.
Tried to fix it by recreating storyboard but this broke other things. Got frustrated. Recreating project from scratch. Printed out code before I add storyboard elements so I can simply drop the working code back into the project and start the main storyboard over again if I have too.
Working on a different problem now. Cannot get my iPad to run my project. Popup box says to reconnect iPad. Reconnected iPad. No change. I can see my iPad in the Apple Music app. Ejected iPad. Tried again to run app from Xcode - changed the target device to my iPad ( also lists the available simulators)
Did not work.
Ran the iPad simulator with same generation number. Worked.
update the iPad to ver 15.
Tried again to get the app to run on the my physical iPad. Same error message.