SwiftSlowly

100 Days of SwiftUI – Day 28 – Hacking with Swift

I’m pretty happy that this review day landed on a Sunday. It lets me go over my previous posts and to enjoy the Superb Owl.

That’s where I want you to reach with SwiftUI – to know that when you have a new project idea you can reach for part of project 1, part of project 3, part of project 4, and beyond, and already be 75% towards your goal. You’ll get there – just keep coming back each day!

Categories:

100 Days of SwiftUI – Day 27 – Hacking with Swift

I’ve decided to change the default title for these posts to reflect what resource that I’m working on and make sure that all post related to my journey with Swift are in the “SwiftSlowly” Category.

Today’s activity is about CoreML and I can already tell that it’s going to be something that I’m going to have to review a little more.

Today we’re going to build our project, combining both SwiftUI and Core ML in remarkably few lines of code – I think you’ll be impressed.

The source material is amazing!

I’m looking at the things that haven’t kept up with when the original material was created as an opportunity to get do my own research. For example, changing the call to the CoreML model.

Some of the methods are deprecated.

Luckily, I found a post about using duckduckgo and found a solution.

For extra cool points, I’m excited that I can still follow along with the understanding of what changed as far as the method call. My understanding is that the method calls to CoreML have changed. I don’t have the why at this point.

I’m also hoping that I’ll learn a better way of handling errors other than printing to the console, but that can be added to my technical debt pile.

Categories:

Swift Slowly: Day 40 - Hacking Swift 26

I’ve finished a quarter of the program! I’m pretty proud of myself for doing that. With everything going on it was good to have a nice project like this to work on.

That being said, I was very happy to see the following quote.

However, I want to say that if at any point you’re feeling tired, or if life just gets in the way, take a break! If you come back to your code in a day or two, you’ll be more relaxed and ready to learn. Like I said at the beginning, this is a marathon not a sprint, and you won’t learn effectively if you’re stressed.

I’m very tempted to take today off, but I’m also just as pumped to play around with the material before WandaVision comes on tonight.

Categories:

Swift Slowly: Day 39 - Hacking Swift 25

Today is a consolidation and challenge day! I’m a quarter of the way through this and I’m pretty excited and grateful to have made it this far. With that comes a little more stress as I’m venturing out on my own to do small challenges along the way.

Which brings me to the challenge!

Challenge

You have a basic understanding of arrays, state, views, images, text, and more, so let’s put them together: your challenge is to make a brain training game that challenges players to win or lose at rock, paper, scissors.

The first thing I did was take some time to sketch out what I want the application to look like.

Rough Sketch with my rubber duck partner.

It really didn’t take that long to get something on screen.

Barebones of an application ui.

I’m taking a lot of the lessons and code from the Guess the flag game that I created earlier in order to move forward with this. I was fun to put the application together and I even spent some time doing some customization.

Application at the end.

What took me the most time, was actually coming up with the logic to the game. Apparently, working on something complex after many days of not getting enough sleep can wear you down. Luckily, there is pen and paper and the ability to forgive myself and move on.

My note book explaining the logic to myself

I’m just happy to be done!

Categories:

Swift Slowly: Day 38 - Hacking with Swift 24

It’s the middle of the week and it’s a good time to do some Swift development!

I’m a little struck by one of the things that Paul wrote in today’s exercise.

Albert Einstein once said, “any fool can know; the point is to understand,” and this project was specifically about giving you a deeper understanding of what makes SwiftUI tick. After all, you’ll be spending the next 76 days working with it, so it’s a good idea to make sure your foundations are rock solid before moving on.

Today’s activity is to go back and cement what I’ve learned by accomplishing three challenges. I get most of the changes, but it seems like some of the code has changed over time.

Extension error.

I got the other part of the challenge working, but it seams like the logic for ViewModifier isn’t working with my current release of Xcode/Swift.


Update!


Another user let me know that .fontWeight is only on Text. I was really preoccupied that the challenge needed to work on views. I handled this by having multiple methods; one for Text and another for Content.

struct Title: ViewModifier {
    
    func body(text:Text) -> some View {
        text
            .font(.largeTitle)
            .fontWeight(.black)
            .foregroundColor(.white)
    }
    
    func body(content:Content) -> some View {
        content
            .font(.largeTitle)
            //.fontWeight(.black)
            .foregroundColor(.white)
    }
}

Categories:

Swift Slowly: Day 38 - Hacking Swift 23

Today’s activity is research.

I’m a little nervous about what is coming next because this was the first time that I saw the syntax for templates and custom containers.

I’m going to have to read it again before I go to bed and hope that it makes more sense in the morning.

Categories:

Swift Slowly: Day 37 - Hacking Swift 22

Today, I was reading reddit like I normally do and I came across a quote on the GetMotivated forum.

Slow success builds character. Fast success builds ego.
Slow success builds character.
Fast success builds ego.

I think it fits with what I’m doing with Hacking with Swift program.

Categories:

Swift Slowly: Day 36 - Hacking Swift 21

Project 2, Part 2 almost sounds like a title for an action parody, but it’s the title for today’s work. I think the following really captures what I’m feeling:

Oprah Winfrey once said, “do what you have to do until you can do what you want to do.” By the end of this 100 days course I hope you’ll be able to do exactly what you want, but in the meantime stick with it – you’re learning key skills here!

To be honest, the first app does looks very basic in the middle of the project and I feel like I’m fighting my own ego in the fact that my application isn’t on the same level that you’d see in the app store. Then I have to take a step back.

I’m just learning!

Of course my app isn’t going to look that great!

If this is what I can do in a few weeks with only a couple hours every day, then the things I’ll be able to do after 100 days will be better. The things after a year will be better still.

It’s all part of growing and I that’s why I’m here.

In the end, I think I made a pretty good starter.

Guess the flag game.

Categories:

Swift Slowly: Day 35 - Hacking Swift 20

I’m fresh off the high of creating my first application and I SO want to charge ahead. I keep thinking “It’s a marathon, it’s a marathon, it’s a marathon.”

Today’s activity is pretty fun in that it allows me to experiment with colors. I spent some time just messing around with how to expand my application.

Categories:

Swift Slowly: Day 34 - Hacking Swift 19

Today is challenge day!

I’ve been looking at the page for about 20 minutes. Then surfed the internet for another 20.

I’m procrastinating.

I’m intimidated because I’ve been playing with Swift for a while but this is the fist time that I said “Hey, I’m going to make an app”.

It’s always been accompanied by some tutorial instructions.

Well, let’s start!

The first thing I did was use Xcode to check in the initial tutorial code changes.

Using Xcode for git

Xcode uses a lot of space for the check in.

Then I realized that it’s a completely new app so the checkin wasn’t really needed.

After that, I was using the preview in order to work on smaller segments of the program. Although, I think this part was kind of disconcerting because the preview would stop anytime that put a piece of code that had an error and wouldn’t start up again automatically.

Xcode halting preview

I’m sure that I’ll remember the keyboard short soon.

I also got a chance to mess around with the refactoring tools in Xcode.

Changing the name of variable

I reminds me of this quote from Phil Karlton, There are only two hard things in computer programming: cache invalidation and naming things.

In the end, I got the application running!

My first application

Categories: