Week 2 of ISYS2160 - Learn to Program Using Swift & SwiftUI for iOS Development — Online.

Suppose you want to know what I think about the class and why I took it. Check my week one review, but for those who have already read week one let’s dive right into week 2. Also, I have changed my mind about taking the course and learning online in general; more about that further in the reading.
Challenges: First Challenge!

As soon as we started week 2, the first real challenge was to recreate what you see above, a Namaste state image with two buttons at the bottom separated by a divider and a Text view under the System.image, and here are my results for my implementation:

I took the sovereignty of writing in Arabic because why not? Also, I did not particularly appreciate how the original image had the palms of the hands touching the sides of the Content View frame, so I added a .frame, as for the color I picked .orange.
By the end my code looked something like this:
Image(systemName: "figure.mind.and.body")
.resizable()
.scaledToFit()
.frame(width: 400, height: 350)
// The .frame(W:480, H:350) is added in order to prevent
// the image from touching the sides of the Content View.
.foregroundColor(.orange)I like how it turned out, and while doing it, I learned about V Stack, Z Stack, and H Stack and when to use what and what Z Stack is used for, which I’m thinking of maybe writing a separate blog to explain Z Stack in more detail, but that might not take place, since as I said, my feelings have changed about the learning online.
Second Challenge!
Now the second challenge was complex, but I might have been tired, or I might should have given myself more time to work on it, but what I know for sure is: I did overthink the answer, which looked like this:
Button("Show Message") {
if messageString == "You Are Awesome!" {
messageString = "You Are Great"
} else {
messageString = "You Are Awesome!"
}
}
.buttonStyle(.borderedProminent)That is the correct answer. However, my code looked something like this:
Button("Show Message") {
if messageString == "You Are Awesome!" {
print("You are great!")
} else if messageString == "You are great!" {
print("You Are Awesome!")
} else {
print("Something went wrong")
}
}
.buttonStyle(.borderedProminent)You can see where I went with this because “You Are Awesome” is there. It will bring the other String, and the other String would get back the first String, but that was not printing anything, and it slipped my mind that messageString = Empty String. Therefore, maybe that is why it didn’t show any results, but at least for now, I wouldn’t know till I get further in the course and do more practice. Nevertheless, there is a more elegant solution to all of this, and I’m sure if you know a thing or two about Swift, you are already thinking about it, which the elegant solution would look something like this:
Button("Show Message") {
let message1 = "You Are Awesome!"
let message2 = "You Are Great!"
if messageString == message1 {
messageString = message2
} else {
messageString = message1
}
}
.buttonStyle(.borderedProminent)Also, there is always the possibility of using a Switch statement or the ternary operator, but that is a conversation for another time. What I’m trying to say here is that I tried, failed, and then learned, so moving on!
Third Challenge! (The HARDEST, and most FUN!)
For the third challenge we did learn how to add an image asset into the assets folder, and that is no big deal, but then we need to use the ternary operator to change the image every time the user click the button, which also switches between the strings of “You Are Awesome!” and “You Are Great!” and that was super fun to figure out. Also, I had the best joy when solving this challenge!
Button("Show Message") {
let message1 = "You Are Awesome!"
let message2 = "You Are Great!"
let imageName4 = Image("image4")
let imageName0 = Image("image0")
messageString = (messageString == message1 ? message2 : message1)
imageName = (imageName == imageName4 ? imageName0 : imageName4)
}
Last Challenge. And the end of the honeymoon phase!
In the last challenge, everything we learned we needed to take into practice, we need to make the text under the text to change but randomly and the image to change randomly as well. Here we got to learn about [Int.random(in: 0…9)] which 0…9 is the range from 0 to 9.
let dice1 = Int.random(in: 1...4)
let dice2 = Int.random(in: 1...4)
let dice3 = Int.random(in: 1...4)
let result = dice1 + dice2 + dice3
print("You rolled \(result)")
print("Coing Flip: \(Bool.random() ? "Heads" : "Tails")")
let messageArray = ["You Are Great!",
"You Are Awesome!",
"You Are Sweet!",
"You Are Nice!",
"You Are Smart!"]
let results = messageArray[Int.random(in: 0...messageArray.count-1)]
print(results)The code snippet above shows the results of the practice with Xcode playgrounds, and with the same concept being applied to our main code, I had the app up and running after less than 7 minutes total, nice! but… I’m ready for a divorce at this point with the idea or concept of online learning without an actual live mentor for feedback.
Conclusion and further context about online learning main issue:
I have changed my mind about taking the course because of online learning, and I still think the course is the best online, yet I think taking the course without a mentor or someone whom you can ask questions and whom would look at your code and give you direct personalized feedback is pointless because you will not learn in any other way in an effective manner, I had so many questions and things I wished I could ask about, but there was no one to ask. However, taking the course in person is the best approach because I can ask the instructor directly if I have any questions, and get direct live feedback, and learn faster. Yet, if you are new to programming like me and want to learn from 0 to being a hero, there are better ways to learn than this course or any other course online for you and me. Granted, in terms of content, this course is the best! But it needs to be improved on the mentor side because there is none, not even a discord, and even discord I think is pointless without a professional direct support system. I guess that is why CodeInPlace from Stanford succeeded, because it had the mentor aspect, and also MOOC.Fi the first official version with mentor support, before that version shut down, since so many students signed up. However, they brought it back, but this time with Python instead of Java, and it is only open for the year 2023.
Learning without a mentor is pointless because what could take two minutes of a single question to be an answer is way better than overindulging your head into the wall, at least that is my personal opinion.
I’m unsure if I would keep going with the course, but I have mostly moved on if you did not see me writing about week three. I will wait until I can take the class at my university, in person, with mentors and tutors, and go from there instead of trying to self-learn because that is not my style I suppose. Again, the course is the BEST ONLINE in terms of explaining things and being available online, but the issue it had is the main issue of every other course, the need for mentorship, which is unavailable.
You might ask why you took the course then? The reason I did, is because I thought since this is a college class, or at least the videos are based on a college class then things would be different, but they are the same, yet I did enjoy the ride, but I’m not sure if I want to to keep going with it anymore.
My advice.
If you can take the class in person, please do it because it is the best, and if you have the privilege of taking the course in person, that means you are admitted to one of the best colleges in the world, Boston College, so congratulations.
Yet, if you are considering taking it online, try it but do not get your hopes up. And if you can find any Swift course/class to take in person or online with a mentor, then go with that instead. Moreover, please don’t feel bad about skipping this course or any courses online because I feel your struggle with not having a mentor. It is not fun, as it feels like you are the poor kid watching the other kids play on the grass field while you are standing outside.
Note: Everything written is my own thoughts and ideas. I was not endorsed or encouraged to write or talk about the course in any shape or form.
