Angela Yu Xcode 12 Course - Part 14 (lectures 164 to 166)

So I'm cracking on with this, even though it's not quite working! To be fair, using Cocoa Pads, JSON, parsing, firebase...it's a lot of new concepts all in one go. The good thing is that I am not deterred; I will complete this chapter soon then keep absorbing everything I can in this course. It's been difficult finding time for coding lately. I am still aiming for 3 hours per week, which is slow but steady stuff. Anyway, let's get stuck in!

Start Time - 18:34

*Interrupted by 12 mins!

So I've picked up a couple of little useful things - again the command button and /
That basically uncomments/comments a whole block

    func updateWeatherData(json: JSON) {
        
        let tempResult = json["main"]["temp"].double
        
        weatherDataModel.temperature = Int(tempResult! - 273.15)
        
        weatherDataModel.city = json["name"].stringValue
        
        weatherDataModel.condition = json["weather"][0]["id"].intValue
        
        weatherDataModel.weatherIconName = weatherDataModel.updateWeatherIcon(condition: weatherDataModel.condition)

    }

This is all confusing and the parsing bit is complicated. But like I said, I'm sticking with it for now! Only got about 15 minutes coding time left...

A bit about force unwrapping and the app crashing.

Segues

I'm pretty good at these already - have done them quite a few times! Setting up something e.g. a button then linking it to another view controller. 

OK a key thing here - to get a second view controller you need to do a new cocoa touch class. That's what I didn't do before on other projects!

OK the other way of setting up a segue is with the yellow button - but that's more complicated. 

ALSO with segues, you need to connect the button, then put in the main body of the code performSegue and the rest of that code. I haven't done that before but I'm sure it still did work. Anyway, it's good to know a more 'official' way of doing it! Right that bit is for the yellow button bit. 

So the first way looks better. 

Finish Time - 19:16 (30 minutes total)

Right so the code and bits needed for transporting data between them is quite complicated. I have skimmed through it a bit admittedly, but I get the purpose of it and will have plenty of more chances to try that out! Time to stop now but a good little addition. I will find more time tomorrow - just half an hour here or there is something!




Comments

Popular posts from this blog

*Xcode Project Entry 2* F1 Quiz - part 1

Angela Yu Course Part 10 (up to lesson 112)

Angela Yu Xcode 12 Course - Part 7 (lectures 74 to 79)