While working on my zentangles app, I added a spinner that appears when the app is fetching or saving data to CloudKit. This appeared to be working wonderfully. But then I tried using the app when I didn’t have access to the network. The spinner appeared and never disappeared.
Not Good!
I immediately thought of a couple of things that might fix the problem. Things like setting the time out for the network operation, using the Reachability frame work to detect when there was no network. But when I attempted to set the CKOperation’s time out, Xcode told me I was using a deprecated function, and I should really be using CKOperationConfiguration. Groan! I thought. This new things is likely just helping some obscure use case that doesn’t apply to me.
Sure enough CKOperationConfiguration has a timeout interval property, to let me do what I thought I needed to do. But then I noticed another property called qualityOfService that can have one of the following values: background, utility, default, userInitiated, userInteractive. Hmm, the header describes the behaviour for these different values…
As an aside, I find myself a bit confused on the subject of timeout intervals. It appears the operation’s configuration has a default timeout of 60 seconds. When I run in a simulator and disable networking on my computer, it appears to time out after 10 seconds When I run on an iPad, not on any networks, it appears to never time out. <Shrug Emoji>
Regardless of timeout confusion QualityOfService is a much smarter way to describe a network operation. When I set QualityOfService to UserInteractive and then attempted a fetch on a device with no network, the operation immediately failed. (likely thanks to internally using Reachability?) Awesome!
I do still have a couple of questions about Quality of Service.
Are there any behaviour differences between UserInteractive and UserInitiated? From the table above, they appear to be identical, but the devil may be in the details.
Is there a way to create a hybrid approach? ie can I get a result right away that will make my spinner go away, but still do retries? Perhaps I don’t really need a spinner on a network operation that is just sending updates to the server….
I recently came across a quote that is playfully witty and wise. The character that is speaking is nine years old and has been home schooling, but now is facing the prospect of switching to learning in an actual school. Unfortunately she is reluctant. She is also a very clever lovable free spirit.
Sasha, the main character in the book, has just suggested that going to school will allow Nina to broaden her horizons. After she first asked Sasha to clarify what is meant by broadening one’s horizons, she says this:
Rather than sitting in orderly rows in a schoolhouse, wouldn’t one be better served by working her way toward an actual horizon, so that she could see what lay beyond it?
Nina Kulikova in A Gentleman in Moscow by Amor Towles
I find myself agreeing with her assertion. (as somebody who has occasionally enjoyed working his way toward actual horizons) But I also find myself confoundedly disagreeing (as a parent who has sometimes had to tell kids they need to do something they don’t want to do.)
For better or worse, Nina does go to school and is eventually swept up in life trials and tribulations. I don’t know if she would have been better served by heading toward actual horizons instead of the school house.
I suspect the people close to me have noticed that I spend a lot of time looking at license plates. As kids, we would spend our time in the car searching for license plates and then trying to find words that used the letters on the license plate. (of course in the order they appeared on the plate.) So for example, for VCM 620 the first word I think of is ‘vacuum.’
As we got older, we’d get bonus points for things like having the first letter on the plate not be the first letter of the word. We would usually start by trying to get away with something like ‘revacuum’ or even ‘revacuumed’ to also pad the end of the word. But with time it became seen as lame to mindlessly stick a prefix and/or suffix on a word. Eventually we would aspire to have the first and last letters truly embedded. ‘Servicemen’ is a word, right?
I definitely don’t remember every license plate of every car we’ve ever owned, but I do remember quite a few. GEK is an early one I remember. We had an NBA for quite a long time. The first car I bought myself was an SKV. Our current car is an XAD. More than once, I think I’ve weirded out friends by knowing their license plates.
Sadly as the number of cars on the road continues to grow, the arrangements of letters and numbers on plates get more varied and creative. Ontario, for example, use 4 letters and three digits. BC has recently moved to AB1 23C as the format of choice. The headache for the Ontario scheme is making sure no curse words make it on any plates. (Three letter plates obviously have a much shorter list of words to contend with)
My current license plate game is to turn the numbers into a letter that they look like and seeing if the resulting ‘word’ can be pronounced or even better have some sort of meaning. The numbers map to letters as follows:
0 -> o (duh)
1 -> I or L
2 -> Z (tho I’ve recently wondered if it could be an N on its side)
3 -> E
4 -> A (some people find this to be contrived)
5 -> S
6 -> G
7 -> L
8 -> B (tho something W8 could be read as ‘wait’)
9 -> G (it looks a bit like a lowercase g, tho looking now, it also looks like a lower case q)
Following these rules, one of my favourite finds is CR8 04K which would be “Crate Oak”