SwiftSlowly

Swift Slowly: Day 23 - Hacking Swift 6

Closures!!!

It took me a while to understand1 but this run through has really cemented how I look at them and just working with them in different tutorials.

For example, I had no idea what the section on “Closures as parameters” actually was saying. Now I can read the code and understand it.

Getting all the answer correct

I’m really excited and proud of myself! I did get a little too excited when I start the trailing closure syntax, but I can see where I went wrong versus just scratching my head about it.


  1. I’m still working towards understanding. ↩︎

Categories:

Swift Slowly: Day 22 - Hacking Swift 5

Today, I decided that I’d use CodeRunner to look at the examples found in the tutorials. It’s part of SetApp.

CodeRunner running a code.

It’s simple and I can just run the code that I want without the overhead. Plus it catches errors that are in code, which helps when I’m going through tests and logic.

Error within application

At this point, you can really, really tell that the lessons are building on top of each other and you can’t rush through them.

Getting a problem wrong

I don’t like making mistakes. When I do, it drives the lesson home and keeps me awake and cautious of what I’m doing.

Error message when you make a mistake

As an added bonus, I’m learning that mistakes shouldn’t effect my ego so much.

Also, I can definitely get along with someone who writes this kind of code.


enum PizzaErrors: Error {
	case hasPineapple
}

Categories:

Swift Slowly: Day 21 - Hacking Swift 4

Today is all about loops.

I learned that you can’t loop over a tuple. I think this is because you can’t guarantee that every item will be the same thing.

I got to spend some time look up how to get a real going because it feels like forever to check my answers in a playground sometimes.

Categories:

Swift Slowly: Day 20 - Hacking Swift 3

I want to point out that I really enjoy the brief discussions on why things are the way they are in Swift.

Why do things this way in Swift?

I got into a grove with the operator overloading and made the assumption that ** was an exponent operator.

I found myself talking through the training and that really helped me with understanding.

I think I’m in the same boat as Paul when it comes to the ternary operators.

I’m very much in the “avoid where possible” camp because even though this code is longer I do find it easier to follow:

I didn’t know that switch statements read the value they were reading once as compared to the if statement which would read it every time that it does a comparison.

Categories:

Swift Slowly: Day 19 - Hacking Swift 2

The introduction of complex data types: Arrays, Sets, and Tuples. I normally get sets and tuples mixed up hopefully not after today. I spent some time going through my older run throughs of the material.

In a previous attempt to make it through the 100 days, I had created an Xcode playground with pages for the different days.

Hacking with Swift playground

I’ll brush this bad boy off and use it to take notes. One of the gripes that I have that waiting for results feels kind of nerve wracking as I’m looking at the little spinner in the corner of the status bar.

I liked using playgrounds sometimes to see if certain lines are valid.

Using raw values with associated types

Apparently, you can’t use raw values with associated types in enums.

This one took a while, but I think this time was just a little more fun to do.

Completed!

Categories:

Swift Slowly: Day 18

Working through Paul Hudson’s excellent 100 days of SwiftUI. I thought about changing the title to reflect the fact that I’ll be going through this but decided to stick with this to show that it’s part of a greater arch.

Notable things

Having the _ as a number separator is kind of fun to think about because it reminds me that not every language looks at the comma , the same way.

I like the fact that every section that I’ve looked at has an option page on “why” something is the way it is.

A section pointing to why something is the way it is.

Overall, a very good start to an addition of my programming habit!

Categories:

Swift Slowly: Day 17

The last day of my run through!

I get to run the completed application.

Tomorrow I’ll start going through Paul Hudson’s Hacking Swift tutorials.

Categories:

Swift Slowly: Day 16

Work got busy and then the Country’s Capital got attacked so I didn’t put any time into my programming.

Well. It’s time to get back to it. I don’t want not working on my task to be a habit!

Section 4: History View

Purpose: Create a simple view for the history of the the user’s scrums.

The tutorial certainly reads very well, but every once in a while, you run into a scenario where I feel that they probably could have made it a little better. For example, in the history view we give the preview a string for the preview. The website doesn’t read very well in the browser page that it’s on.

Long string text in xcode

Of course, it looks a lot better when it is in Xcode.

Long code line in Xcode

I couldn’t stop messing with the code because I wanted the properties for this thing to stick out.

Long command line reformatted

I’m hoping that if I start using source control for this, I’ll be able to go back and refactor a little easier. This might just be attempting to optimize for something that doesn’t need to be optimized.

I need to do some research on how the extension keyword works in swift and at what point. Extension of the history classI think I understand that we placed it here because no other view needs to do a translation of the attendees array. A discussion on refactoring is most likely not going to be part of this tutorial.

I’m going to finish the last section tomorrow.

Categories:

Swift Slowly: Day 15

This is the last section of the tutorial.

There were a lot of distractions today, but I’m going to finish this so that I can move on.

Section 2: Integrate Speech Recognition

Purpose: Introduce the code that will allow the application to record speech.

Although the time to go through this is pretty quick, you would really want to go back and take your time to understand how it’s calling access.

Section 3: Display Recording Indicators

Purpose: Learn about dynamically toggling interface elements to let the user know that they are being recorded.

It was pretty fun to do this section, but I’m still reminded that I don’t like ternary statement. The reason for this is that the question mark means it’s an optional if it’s next to the variable but it’s a ternary if it’s not. The rest of the statement should let the developer know, but if you are new or coming back to an old code…

Categories:

Swift Slowly: Day 14

This is the last section of the tutorial and I’m wondering what I’m going to do after this. I’m going to just do one section today because tomorrow is a big work day.

Section 1: Request Authorization

Purpose: Show how to get use of the phones different functionalities like control of the mic.

The first step is to click the “Add (+)” button but it doesn’t show up unless you have the mouse over one of the properties that are already defined. The interface has a lot of white space that could have been used for something like this and it’s a little misleading.

This is the first time I’ve seen autocomplete not work because of case sensitivity.

The string 'priv' doesn't find Privacy.

Categories: