Learning Native IOS Week 2

Week 2 Here We Go

Ok week 2 has started for this class and it's already done, in terms of things I need to do... It's only week 2 so the material is still trivial, however I expected it to be not as basic as it is. The focus of this week was practicing Swift programming (which I already got a jumpstart last week) and this was done using XCodePlaygrounds. Playgrounds is a quick to setup environment to do quick programming. I believe you can play around and setup an visual interface as well, especially given that I saw that Swift Playgrounds can be run directly onto your mobile device which is pretty insane. The professor said that Apple has an explicit rule that apps cannot compile code, however they break their own rule with this app which makes me wonder if there could be another class action lawsuit similar to the one that Epic enacted against Apple some time ago in the future... The class lecture itself was interesting going over some history stuff, but the actually programming part was too rudimentary for my taste. 

The class has both undergrad and graduate students so it makes sense that we have to touch on the fundamentals for the less experienced, however I would suggest a separate class that moves way faster. I did learn some cool things about Swift that makes me wonder what other languages have similar features like being able to override binary operators (+,-,*,/,+=,-=,*=,/=) and there are lots of keywords that will take me a hot second to memorize permanently. Last week I was kind of annoyed that I had to type the name of the argument and the value of the argument when calling a function, but specifying an underscore before the argument name in the function declaration overrides this requirement (makes the argument generic). 

I can appreciate though having to specify the name of the arguments, it can clarify what the actual arguments are (increase code readability) so it really depends on the situation if you should use that feature or not. If the function is something like add2Numbers then it might make sense to use the generic feature because, it's really unnecessary to know what the names of the arguments are. However, if it's something like a helper function that has many arguments for a binary search then it would make sense. Interestingly enough, in some languages when specifying the argument names the order does not have to match what was declared in the function declaration but in Swift the order still has to match.

The assignment wasn't that big of a deal, we just had to write a binary search that can find keys in an array. We also had to add more code to a Fraction class that we went over during the lecture to override subtraction, multiplication, and division. I split mine up such that the Fraction class lived in the source folder so that every page in the playground (essentially test files) could use the Fraction class and made a separate page where my tests lived so that it was cleaner to grade. I also learned how to make a class printable when passed into print() which was nice. My trivial code is up on github as usual. 

Now I did say week 2 has started and is done, but not really because I need to familiarize myself with SpriteKit for my project later in the quarter. The professor said I could use it so I hope to make something fairly nice. I might be able to use some assets from work which I'm sure they'll be ok with if I decide that they could be useful. I also have plenty of assets from my previous projects so I might repurpose some box art that is lying dormant on my harddrive.

No screenshots since there really isn't anything to show but here's the github. I might come back and revisit this post if I make progress with SpriteKit.

Github: https://github.com/voporak5/mobile-app-ios/tree/main/HW2

Update*

I managed to spend some time with SpriteKit and apparently GameKit since selecting the "Game" option when creating a new project setup a scene that imported both of those. Still learning the syntax but Swift is weird. Getting a sprite in there that responds to physics wasn't too difficult. I found a webpage that told me exactly what I needed to do and it's straightforward. Here's a screenshot of 2 sprites that do respond to collision although the screenshot doesn't show any collision... No github yet because I grabbed that art asset from work so I'll need permission if I am to make it public.
Here's what I used to setup collision https://riptutorial.com/sprite-kit/example/24162/simple-sprite-kit-project-showing-collisions--contacts---touch-events-



Comments

Popular posts from this blog

Tips For Working In The Database - Tip 1. Always Write It Down

Tips For Optimizing Collision