Schneider Chalet Cuckoo Clock

cuckooThere is no timepiece outside of a majestic grandfather clock that can match the charm of an authentic cuckoo clock.

My mother recently traveled to Nuremberg, Germany to attend their Christmas festival. While there she bought us a cuckoo clock and had it shipped back home and then to us for Christmas. I’ve shared a photograph of the cuckoo in situ.

It’s something I’ve always wanted in the home and something to pass down to the kids as something fun. It hasn’t been without it’s challenges. It’s a 1-day winding movement with rotating people and a cuckoo. It plays a tune after each cuckoo event. I hung it in the kitchen but the ticking and the cuckoo proved to be too distracting for some, so I moved it into the dining room.

However, after moving to the dining room the minutes hand started to stick as it neared the 12 o’clock position. I tried all kinds of things to remedy the situation. As it turns out, there is a switch on the left side that operates always cuckoo, cuckoo w/o evening, and no cuckoo. The switch was nudged into a position between two and thus provided friction internally – stopping the minutes hand from free movement as it neared the 12 o’clock position. Now she’s running fine again.

Swift CAKeyframeAnimation & counting sheep

Today I had the need to create a looping animation of a looping series of sheep – much as you’d imagine a child counting them. This is what I came up with tonight, after having about zero experience doing this kind of thing.

I performed a lot of trial and error here, and the delays for getting more sheep activated might not be the right approach… I didn’t see a way to delay animations any other way (yet).

Here is my entire code for this effect – I can explain when I have more time to actually walk through the code and explain what’s going on. I think it’s fairly self-explanatory and once you do this, it becomes easier to think about.



Extension management for Swift projects

The way that extensions are handled in Swift is lovely. If they exist in any file, they are available project-wide. Meaning you don’t need to import them into a Swift file for functional inclusion. This is great! But if you’re working on a medium to large Swift project, you may need to tweak or add functionality to an extension or two over time.

Find In Project and other avenues of searching are available within the Xcode IDE. That introduces some cognitive load and possibly causing you to lose a thought while you’re doing some menial tasks finding code.

A solution.

You can make an Extensions.swift file in your project and keep all your extensions in it. Import what you need at the top of it – usually UIKit should suffice. You could use //MARK: – UIView – type browse tags in your code to break things into categories too if you needed to.

Pretty handy!

An example to get started.


Apple Watch after WatchOS 2.0.1

IMG_0949Based on my previous post about my Apple Watch, I was hoping for Apple to do something with an update release for WatchOS. I still wasn’t getting close to a whole day on a charge but it seemed a bit better than before.

One thing I noted, and I offer this suggestion. If you charge your watch near or close to a large table fan at night, the magnets in the fan might be fooling your watch into thinking it’s fully charged when it’s not. I have since moved my charger and I’ve noticed much better performance.

Anyway, I am now putting the watch on around 8:00 AM and by around midnight, I am still around 65% battery. This is after 2.0.1 was installed. I don’t know what bugs or internal features Apple has made, but they have significantly stretched battery life for me. I don’t keep the battery complication on any watch face any more because I don’t have to worry about battery at all. It’s pretty liberating. I know my experience shouldn’t have included worrying about battery life to begin with, but now that it’s been addressed, I am quite happy.

Thank you Apple.

Swift: Animating a mask for a UIView

Animated Image

I recently stumbled upon a really excellent article online entitled “UIDynamics, UIKit or OpenGL? 3 Types of iOS Animations For the Star Wars.” A lot of great discussion about performance of interesting techniques in a iOS user interface. I read through it and without going to the Github repository to check out any code I decided to try to replicate that mask animation.

I am not a huge fan of Google’s Android Material Design, but the animated mask aspect of a user interaction is interesting, attention grabbing without being too heavy-handed, and playful. And it was a bit of a challenge as I have never tried masking anything at all in an iOS application.

By the way, I have a handy extension that you might love for use in Swift applications. It allows me to provide hex values to provide UIColor attributes to things.

Anyway, here is the full view controller class. The method close and showUnderView is where the masking action takes place. Make careful consideration of the order in which you add subviews. Here is an example of what I have going on.


Swift: Accessing a view controller’s methods

Recently in a Swift project I was using NSNotificationCenter in a bunch of places so that my custom UIView classes could end up calling methods in the ViewController class. After a while I started getting notification bloat and it became a little confusing managing all the posting and listening. It was a bit of a mess for my tightly-coupled views and view controller.

So this is how I can call methods and stuff in my ViewController from my custom UIViews.

It’s a LOT easier to do this than setting up all those notification and observers. I think you’ll agree (unless you have very loosely coupled logic) that this is a nice solution and it works for Swift. I wasn’t sure how to set it up outside of how I approached it in Objective-C.

My Apple Watch Review

I waited a few weeks after the release of the Apple Watch until I pulled the wallet trigger and fired money Apple’s way. I figured the initial rush of inventory stock might have some manufacturing defects. Their attention to detail and polishing of their brand at every turn probably made that decision daft, but I held out a little while nonetheless.

Upon placing it on my wrist, setting a passcode, getting music on it, getting notifications, etc. I was in love. What a wonderful device that performs it’s tasks perfectly. Battery life was more than wonderful. Then after a few weeks, the battery started to drain quicker than normal. I would get about eight hours of life from it. I started to worry, played around by lowering the brightness, removing glance items, un-paring and re-pairing, resetting, etc. It didn’t seem to help very much.

Then I’d get five hours before it would die. I bought a second charging cable for work so that I could get some more battery charging complete to last me through the afternoon. Then I started to turn off Outlook notification and I said enough is enough. I booked an appointment at the Natick Collection genius bar.

They couldn’t connect to it to perform diagnostics, knew all the hoops I jumped through in order to fix the situation. They offered me a brand new watch which I gladly accepted. I took the second watch home and set it up as a brand new watch – no backup.

Ten hours battery life. That’s when I realized that something was amiss with my iPhone 6+. I checked my Bluetooth settings and saw a bunch of old device profiles stored on the phone. Pre-release stuff. I “forgot” those devices on the phone. Eighteen hours of battery life. A few days later and the watch is humming along at around twenty hours of battery life which is insanely awesome.

I imagine those BT profiles were constantly searching for their hardware (bugs) and somehow affected the watch so much that it was stuck in a terrible high-power loop. At least that’s my theory. The watch is awesome. Sometimes at night while the watch is charging I’ll feel a phantom tapping on my wrist. And I can’t wait until morning to put it on again.

[Swift] Quick number to word conversion

If you’re ever setting content for things using loops (who isn’t, right?), you might often use the loop variable in a string to label something. Item 1, Item 2, etc. Especially when you’re simulating or prototyping something that will consume actual live data later on.

A nice touch is to get rid of those numerals in your labels or other text controls. They look so… engineer. Meaning more function over form. I like both.

Slap this into your loop and set your labels with more care.

Such a tiny bit of code and it really does dress things up nicely. Some might even think that you’ve set up an array of String values and populated using that.

Crazy. As in crazy good.

[Swift] UIScrollView snapping into place like in the iOS App Store

I was asked recently to modify the UIScrollViews that I implemented in an iOS application design. The request was to have our scroll views behave like the ones that appear in the iOS App Store. Here is a screen capture of that ribbon to familiarize you with the scroll view in question.


Alright. In short the behavior prevents cell clipping when navigated to someplace in the middle section of the exposed cells. If the user is at either the beginning or the end of the content, you’ll see peak-through which is desired. But anywhere else, don’t clip the display of a cell on the left side.

I searched around doing the StackOverflow dance and found a few posts about this very thing. One of them mentioned the App Store specifically and that’s where I lifted the screen capture. The explanations were up-voted but when I tried them, they only worked part of the way. I’d get some wonky, sticky behavior. I had to convert many of them to Swift as well as they were offered as Objective-C solutions.

I started to get frustrated – just wanting this thing to work quickly, show it to the person who requested the behavior, and then move on to more pressing application authoring issues. Meaning bigger stuff. So after some time trying to modify someone else’s code to work I decided to junk it and use their concept and code it myself.

The place you want to put some code would be in your UIScrollView’s scrollWillEndDragging delegate method. Make sure that you include UIScrollViewDelegate in your class and to set your scroll view delegate appropriately.

And then

When those things are done, the scroll view will call it’s delegate methods. Here is a solution written in Swift that I used to get this behavior and I’ll explain some if it for you.

Since I had several scroll views in this view, I wanted to make sure I could target them individually. I didn’t set them up as class members – I simply used tags to mark them for evaluation. For instance 1 scroll view has the tag 100, another 99, etc. As long as I know which tag calls the delegate method (they all will), I can address them individually. So in this example I’m looking for tag of 99.

The pageWidth is that scroll view’s cell width including the padding. I’ve hard-coded that, you could use a global variable or whatever. If that number changes when the scroll view is populated with cells, you have to remember to change that value in the delegate method. So it’s a little messy, but not a deal breaker in my opinion.

We then determine which page we’re currently on. We’ll use that later to make adjustments if required. The velocity adjustments are there in case the user wants to “throw” the scroll view contents… since we’re making the scroll view sticky, this makes the behavior a little more like the traditional scroll view in regards to perceived smoothness.

If the user throws with a certain velocity, we adjust how many cell indexes becomes the target. If you have a lot of content in your scroll view, you may want to adjust more for velocity – adding more distance for the offset target. Apple does this in their implementation. They have about 3 or 4 “pages” of content. A high velocity drag has a target to get you to the next batch of off-screen content. It’s slick.

We update the targetContentOffset.x with the target “page” * the pageWidth. When that’s updated, the scroll view uses that and updates it’s target position. You end up getting snapping on your cell content just like you would in the iOS App. It’s not a ton of code either.

A note: I read where people were changing the deceleration of the scroll view to make it feel even snappier.

I tried it and I felt it made things feel too snappy. It reduced the perception of fluidity and made it feel like something was subtlely wrong with the application or control. So I didn’t use the technique and feel good about that decision. Your milage may vary.

Iron Maiden. The Book of Souls review.


Before I begin, I have to say the longer tracks on The Final Frontier (the previous) offering were masterpiece level with me. The Talisman, The Man Who Would Be King, and When the Wild Wind Blows are simply incredible.

Coming into this album, I was very excited. My first listen or two left me wanting… coming of Final Frontier. I’ve listened several more times through on really excellent headphones and now I get it. This album is epic. Epic.


Track 1: If Eternity Should Fail
The synthesizer texture and midi horn is campy. I assume the horn isn’t a real instrument. The vocals in the introduction are very good, and the lyrics are wonderful. The kick in sounds awesome. You can hear all the instruments on this album. The refrain is super nice. This song has a nice hook and the guitar work is what I would call pleasant. Nice gallops. We’re off to an awesome start.

Track 2: Speed of Light
Typical Air Raid Siren scream at the start. Groovier than the first track. This was the single so I’ve listened to it quite a lot already. This will definitely be a tour favorite – it sounds built for refrain sing along. It’s a decent track, if not a little bit expected.

Track 3: The Great Unknown
Nice Harris thumping along at the outset. Bruce sings loosely before the track takes off. The build up is awfully nice before McBrain starts thundering. It all comes together so seemingly effortlessly. Bruce’s voice struggles in spots – he doesn’t sound like younger Bruce at all and it’s apparent for the whole album. However in some songs it actually works for him – namely track 1 so far. On this track it’s a slight distraction. Guitar solos? Here we have some awesome work – not over the top with hammer taps and such, it sounds composed and perfectly in place. It’s not one of my favorites, but it’s decent.

Track 4: The Red and the Black
Really interesting lead in with quasi-acoustic guitar playing. This track in my opinion is freaking epic. It has a slight medieval vibe to the singing delivery and guitar presentation. This is going to be killer on tour. There are “whoa whoa whoa” bits to sing along to. Each section comes with head-banging vocal delivery. There is some almost pop-like stuff going on near the middle of the track. Solos – melt your face off and toss it in the disposal. One solo after another with decidedly different technique and skill brought to it. After the solos the song almost seems to turn into another song with the same groove. This band is so tight that they could probably play variations of their groove forever and it would be interesting.

Track 5: When the River Runs Deep
Bruce’s voice is strained at the start. This is a track that is not one of my favorites on the album.

Track 6:The Book of Souls
Very soulful guitar work up front. Synthesizer textures. A lot of complication and interesting lyrics here. It has an overall epic feel to it, like for the masterpiece movies of long ago. A medium beat to it. At 5:47 it starts to rip your face off with epic Maiden galloping and drum work. Masterful solo.


Track 7: Death or Glory
A fun track but definitely not in the list of top tracks for me. It sounds like it could have come from A Brave New World but thrown out and not making that album. It sounds kind of scripted typical Maiden which is still better than almost any other band’s throw away. Filler? Hmmm. Maybe a little bit.

Track 8: Shadows of the Valley
The thing starts off a little like Wasted Years – a nice throw-back. Galloping guitars and thundering drums. I could say that about most of these songs, but there is a nice rhythm going here. Bruce sounds pretty decent here.

Track 9: Tears of a Clown
Dedicated to Robin Williams. Super progressive guitars and hooks. A decent tune about depression, etc. I almost wish there was less singing on this one so we could just hear the grooves more up-front and to continue the hooks more.

Track 10: The Man of Sorrows
Melancholy introduction with sweet guitar work. This song is epic in my opinion. Bruce oozing with emotion. I usually listen to this song first on the album. I liked the slower stuff from Final Frontier so I guess it makes sense that this song touches me. The lyrics are wonderful. The power tempered. At 1:55 the song is like honey and just drips with a unique gallop. Things are a little more simple – and perfect. The soloing is wonderful and sounds on par with Eric Johnson or Joe Satriani.

Track 11: Empire of the Clouds
Holy shit. Piano. 18 minutes. Epic. I don’t want to describe this song. It’s a great surprise and shows the musicianship of this band and their breadth.