Posts


Jul. 15, 2022

Minimum Functionality for App Store

In my post about my first app, EasterDay, I mentioned that it might be too trivial for an App Store submission. I’ve just been reading the App Store Review Guidelines, and there is a section on Minimum Functionality that seems like it might be too pointless for acceptance.

I’ll push on and build it anyway as I still need the rest of the learning experience, but may not submit it. Of course I’ve got other ideas for apps (like everyone who has ever met an iOS developer) but they are outside my expertise for the time being.

Jul. 14, 2022

awesome-ios list on GitHub

I was looking for some more podcasts with Swift fundamentals content when I came across this great community built awesome list.

There’s a few podcasts on the list I have not come across, so I’ll check them out.

Jul. 14, 2022

Learning Retention

In order to have something to put up on GitHub (as part of working all that out) I went back to re-write the Checkpoint 2 code that I’d written, but not saved, three or four days ago.

The task was to count the unique elements in an array. The teaching had been about the complex data types, so clearly the hint was to cast the array to a set. Although the idea of sets is new to me this year, I’ve come across them twice. Once in the 100 days course (the same day as having to write this code) and once from a few days earlier from a podcast episode . This is high quality learning - getting the same topic a couple of different ways a few days apart, then having to use the information for real.

Jul. 13, 2022

Checkpoint 4

/*
 The challenge is this: write a function that accepts an integer from 1 through 10,000, and returns the integer square root of that number. That sounds easy, but there are some catches:
 
 You can’t use Swift’s built-in sqrt() function or similar – you need to find the square root yourself.
 If the number is less than 1 or greater than 10,000 you should throw an “out of bounds” error.
 You should only consider integer square roots – don’t worry about the square root of 3 being 1.732, for example.
 If you can’t find the square root, throw a “no root” error.
 */

enum IntSqrtError: Error {
    case low, high, noIntRoot
}

func calculateIntSqrt(_ number:Int) throws -> Int  {
    let lowerBound = 1
    let upperBound = 10_000
    if number < lowerBound {throw IntSqrtError.low}
    if number > upperBound {throw IntSqrtError.high}
    // brute force sqrt finder
    for i in lowerBound...number {
        if i*i == number {
            return i
        }
    }
    // none found or we would have returned by now
    throw IntSqrtError.noIntRoot
}

do {
    try print(calculateIntSqrt(5929))
} catch IntSqrtError.low {
    print("Lower bound error")
} catch IntSqrtError.high {
    print("Upper bound error")
} catch IntSqrtError.noIntRoot {
    print("No integer root")
} catch {
    assert(false)
    print("Unknown error")
}

Jul. 13, 2022

Checkpoint 4 optimisation

The Checkpoint 4 task was to find an integer square root of numbers up to 10000. My first pass solution was:

func calculateIntSqrt(_ number:Int) throws -> Int  {
    let lowerBound = 1
    let upperBound = 10_000
    if number < lowerBound {throw IntSqrtError.low}
    if number > upperBound {throw IntSqrtError.high}
    // brute force sqrt finder
    for i in lowerBound...number {
        if i*i == number {
            return i
        }
    }
    // none found or we would have returned by now
    throw IntSqrtError.noIntRoot
}

Although not coded for speed, there are a couple of subtle optimisations here; the first is that it gives up once it gets to the number instead of going up to the end (it assumes the square root of a number can’t be greater than the number), and the second is that it counts up from the bottom rather than down from the top - I’m assuming the bottom of the range is richer in square roots than the top.

Jul. 13, 2022

Gitting Started

One of my early goals was to get in the habit of using version control with Git/Github, and I’ve got that sorted out today. My source was this excellent, very clear video from Gwen Faraday . I highly recommend it if you are just starting.

It possibly helped that I’m also on mac, so I didn’t have to deal with the “or however that’s done on your system” type problems. Also, where things didn’t work as expected, the explanation about what was being done was clear enough that the problem was solvable. For example, the push command Gwen used was:

Jul. 12, 2022

Tuple Pronunciation

Another advantage of the videos, that hadn’t occurred to me when I mentioned it the other day , is learning the correct pronunciation of things you’ve only ever read in books.

Apparently, tuple is pronounced two-pull, and not with the tup to rhyme with cup as I’d always imagined. Google has confirmed, so it’s not just a UK thing.