31 Days Later and I Finally See the Light with SwiftUI

Impromptu Thoughts
4 min readNov 2, 2022

--

After sixteen lectures, two course projects, and a lot of cups of coffee later, I finished the Stanford cs193p iOS development course within the month. I initially gave myself two months to go through these lectures, but after the first lecture I thought that if I wanted to take learning Xcode and iOS development in general seriously then I should bump that schedule up and finish it within the month of October. Finishing sixteen college lectures within a 31 day timespan while working full-time was definitely easier said than done but I am glad I managed to achieve this personal goal and was able to finally understand what was up with swiftUI.

I may have alluded to the fact that I have coded in swift before but only with storyboards and UIKit back in the day so relearning swift with a whole new environment was daunting; and swiftUI really was a new environment. Coming from the UIKit world of UILabels, ViewControllers, and pivoting to a struct-based swiftUI was, I would say, a bit weird at first. The notion that I could just make a struct, add a body and the magic words some View and then have it magically turn into a view was something that really has resonated with me as the month went on. Being able to start from scratch and slowly build up the experience you wanted without interacting with something that, at times, felt limiting like storyboards was a breath of fresh air. Gone are the days of worrying about linking your UIButtons with their actions and wether or not you linked your main ViewController with the proper connection, now all you have to do is code it like many other languages and have swift do the rest.

Saving Data and a lot of Headaches

During the last week, in lecture 13 to be precise, Prof. Hegarty went over how to save data to long term storage in both CoreData and iCloud and it was beyond what my expectations were. To save data long term in CoreData was incredibly simple, like too simple in a way. You could save custom structs, classes, and whole models with a couple of lines of code and when it comes time to call on them, all you gotta do is just read the data.

Now I could be wrong on this but from the vague memories I had playing with CoreData back in the day, aka 2017ish, wasn’t it a lot harder back then or was it just me being naive? Like I remember having to handle data in a certain way in order for it to be accepted by CoreData to be saved. SwiftUI has really streamlined the entire process and then on top of that made it easier to recall it and have the elements that was in storage be ready to be displayed on the view with very few issues.

Now that I completed this course I am thoroughly convinced that swiftUI is leaps and bounds superior to the old storyboard based UIKit ways of the past. Before diving head first into learning about it, I would see debates of it on the internet and was hesitant to even learn more about it, but now I see that this new way of writing swift code is better for us as programmers. It took away certain constraints that storyboards had placed on us, bad memories of margins and inconsistent padding that I didn’t know how to fix come to mind, and allows us to go right down to the bare basic and allows us to build a view as we imagine it. Writing views more freely and with the only limitations being your imaginations and how many extensions you can add to help build your code. After finishing this course I am more dedicated than ever to try and actually use what I learned.

I have decided to start a quick simple project to test out the swiftUI skills I picked up from this course and see if I have fully made the jump from storyboards to swiftUI or if it was more of a tumble. One way of trying it out would be to do the time-tested and ubiquitous weekend project almost every swift programmer has tried, a calculator. I am gonna try and build a simple calculator using elements I learned from this course such as, MVVM, views, viewModifiers, custom views for buttons, and even CoreData if I am feeling a bit — spicy —

This would be my first solo project after learning more about swiftUI and getting back into Xcode more in general, so I would make sure to write about it on here so that I could document my experience and see, in a year’s time or so, how bad I will cringe at my first swiftUI project. :)

--

--

Impromptu Thoughts

Just a guy from NYC who’s trynna get back into programming and takes some mediocre pics too.