Posts

Showing posts from July, 2018

Angela Yu Course Part 13 (up to lesson 133)

Image
I'm back! And so is Angela! Well, the last bit of her epic course is - this time 'Intermediate Swift'. I was going to leave it after Auto Layout but actually felt this would be well worth exploring and completing. THEN it will be time for another Udemy course! Here we go! Classes and Objects The first bit of this is recap - a class containing blueprints e.g. properties and behaviours. The object is an instance of the class. So first up, I've created a new project under MacOS that is a 'command line' file. Something interesting - you cannot call instances/values a keyword e.g. var class would be too confusing! Putting back ticks around it is allowed though it should be discouraged! All of the rest is recap to be honest. Enums This is basically creating a new data type. In our example we're working on, it is a 'car' data type. enum CarMake {          case Ferrari     case Mercedes     case BMW     case...

Angela Yu Course Part 12 (up to lesson 121)

Image
Just a quick entry - one more course so that all the Auto Complete lessons are done.  The Angela Yu one has been fantastic - the best one so far! I thought about leaving her course at this stage to move on to the Ray Wenderlich one, but actually, the next one - Intermediate Swift - looks worth doing first. So after this brief entry, I should be starting Ray Wenderlich's course pretty soon! Auto Layout Using Stack Views These are a recent development from Apple. Putting a number of items on screen that are distributed evenly. Copying over buttons/objects using the alt button - clicking and dragging Another point here is that if you connect a button, then copy it, the copy will link to the code that has been created for the original button. Once stacked, use the object in the document outline to select each one / You can change horizontal/vertical stacking if you need to. OK, so there were several steps to get here - embed stack view, distribute e...

Angela Yu Course Part 11 (up to lesson 120)

Image
Back on a train for around an hour and ready to code! So last time it was really rewarding to crack the use of the if/else statements with the interactive 'Destini' story app. That could be easily extended and amended for lots of things! Now we're focusing on Auto Layout - something I've looked at before on Pasan's courses. I'm sure Angela will make it very accessible and shed some light on misconceptions from before! Auto Layout The point here is changing from portrait to landscape OR change the device type ruins the layout of the different text, buttons etc. The answer to this I know - constraints and auto layout! Resizing the background/canvas is a terrible idea! It would be fine for a different device, but then people have different phones/devices....again the answer is AL! Programmatic auto layout - this I looked at before with Pasan but it was very laborious. It makes more sense to set in constraints. Positioning UI Elements Programatically ...

Angela Yu Course Part 10 (up to lesson 112)

Image
It's unlikely that I'll be able to do any Swift tomorrow as I'm going to Eastbourne today, for the weekend. So I can give half an hour now, maximum! Coding Challenge - Destini App! Choose your own adventure books! I used to ADORE these. Angela explains that these have had some sort of revival through the Lifeline games. It's very binary - yes/no mostly. I have my own experience of this based on WDC... Now the challenge is to complete the game! Having followed the first few instructions, which I found a bit confusing it must be said, I was about to surrender and see the answer. Then I managed to stop myself - I CAN do this, or at least have a good go! Even if I don't get the correct answer, it will be good practice to put what I know into practice. This is my weakness, which I keep coming back to - that when some problem solving is required, I fold far too quickly. So here is what I need to do: Let's break this down... I need to use the...

Angela Yu Course Part 9 (up to lesson 103)

Image
So the plan is to complete this app today - the Quizzler! Like I've said before, this template could easily be adapted. Once it's done, I could use it for F1 questions, GoT...anything! So being able to understand each step, as well as the object oriented programming being clarified, there have been lots of positives. Here we go! Init the First Question let f irstQuestion = allQuestions . list [ 0] I figured out that this must be the 0 index with that format. Makes sense! uestionLabel . text = firstQuestion. questionText          Having the class makes a huge difference to the simplicity of the code! OK, the tag system makes a lot fo sense. Grouping together several buttons and putting in the tags of 1, 2 etc. That would have been useful for the Yahtzee buttons for each option to click. Anyway, that's something to play around with another time.  func checkAnswer() {               ...

Angela Yu Course part 8 (up to lesson 94)

Image
Continuing! Last time, classes were introduced. These seem to be - generally speaking - the way to go in all coding that involves objects. So the first part is going to be about object-oriented programming, something Pasan taught via the 'tower' game. That was a bit confusing to be honest, so hopefully this will clarify things! As before, I only have around half an hour - one our max, so here goes! Object Oriented Programming Machine Code - made up of 0 or 1. Technically, you could run with MC and do billions of lines of this but it would take forever! 1970s - C programming language. This is where all the other languages came from. Procedural Programming Language - Do this, then this, then this....repeated! Restaurant analogy - ONE person doing a long list of things including waiting on the tables, taking the orders...etc etc. Instead, you could have one person for the waiting, one for cooking. Good analogy! So in the restaurant analogy, messages can be passed aroun...

Angela Yu Course Part 7 (up to lesson 90)

Image
Before I go into the next part of Angela's course, I've been experimenting with the 'Yahtzee' app! It's actually gone much better than expected - I've managed to put together this: The dice roll when they are clicked, you click on the number buttons (1, 2 etc.) to assign that score...it took a lot of logic! One of the things I'm most proud of is the diceFunction, which combines several functions and bits of code together! unc diceFunction(diceNumber: Int ) {                  func isDiceEqual( _ : Int ) -> Int {                          var count = 0                          let diceIndexArray = [ randomDiceIndex1 , randomDiceIndex2 , randomDiceIndex3 , randomDiceIndex4 ]                          for x in diceIndexArray...