Category Archives: iOS Development

What’s New in iOS 12.0.1

Lew from Unbox Therapy says iOS 12.0.1 fixes that spurious random non-charging issue, appropriately dubbed ChargeGate. I’m glad the issue has been fixed, although Apple does not officially acknowledge that there even was a problem.

From the Upgrade Dialogue:

iOS 12.0.1 brings performance improvements and exciting new features to iPhone and iPad.

  • Photos introduces new features to help you rediscover and share the photos in your library
  • Memoji—a new, more customizable Animoji—make Messages more expressive and fun.
  • Screen Time helps you and your family understand and make the most of the time spent on devices
  • Siri Shortcuts deliver a faster way to get things done with the ability for any app to work with Siri
  • augmented reality becomes even more engaging with the ability for developers to create shared AR experiences
  • and new privacy features help protect you from being tracked on the web.

For information on the security content of Apple software updates, please visit this website:

What’s New in iOS 12

Straight from the Update Dialogue that we can’t view anymore as soon as we hit “update”:

iOS 12 brings performance improvements and exciting new features to iPhone and iPad. Photos introduces new features to help you rediscover and share the photos in your library, Memoji—a new, more customizable Animoji—make Messages more expressive and fun, Screen Time helps you and your family understand and make the most of the time spent on devices, Siri Shortcuts deliver a faster way to get things done with the ability for any app to work with Siri, augmented reality becomes even more engaging with the ability for developers to create shared AR experiences, and new privacy features help protect you from being tracked on the web.

This update introduces new features and improvements to [the following areas]:

Continue reading

How to assign a variable inside a block in Objective-C

I recently tried to assign a value to a variable I had declared from inside a block. Apple’s frameworks make frequent use of blocks, and as such, I didn’t see anything wrong with this code:

Xcode 9 begged to differ though, telling me that the “Variable is not assignable (missing __block type specifier)“.

Stumped, I had a look around the web, where I found this StackOverflow article that explained it. My mistake was that when I declared the variable above the block. I had no idea this was necessary, but apparently it is.

All we need to do is add “__block” in front of the variable at the time we declare it (more or less precisely what Xcode was trying to say). The error message disappears when we amend the code like this:

Easy – if you know how 🙂

Building a Day Counter on iOS – Part 1

In this series I’ll show you how to create a simple Day Counter on iOS, using Objective-C and Xcode 9. The idea is to set a date in a settings screen, and then see how many days have elapsed on the main screen right after launching the app.

This is a 3-Part Mini-Series:

  • Part 1 is all about building the interface in Interface Builder
  • Part 2 is about coding the NSDate subtraction methods, using NSCalendar and loading/saving data using NSUserDefaults
  • Part 3 will introduce Key/Value Observing to update the first view controller as soon as the date is changed in the settings and deals with how to normalise an NSDate object.

You can find the full code on GitHub:

Happy Hacking!

Watch the full course in one convenient playlist:
Catch this episode on my iOS Dev Diary Podcast:

How to pick a random character from a string in Objective-C

Imagine we had an NSString consisting of a pool of characters from which we’d like to pick one at random. Say our pool is ABCDEFGHIJKLMNOP, and we want a single character.

Here’s how we can do that:

The comments speak for themselves. One thing of note is the typecast of characters.length, which is needed to suppress the Xcode warning “implicit conversion loses integer precision”.

Most of the magic is provided by the NSString method substringWithRange.

How to use Version Control since Xcode 9

Xcode 9 has introduced a few changes in regards to Version Control is now handled. If you’re looking for the once so proud Source Control – Configure menu option, you’ll find that it’s no longer there. Dang! Where has it gone, and how are we supposed to manage our projects now?

Turns out there is a new tab in town, next to the Project Navigator (File manager icon) in the left hand pane of Xcode 9, called the Source Control Navigator. Click on it to find a plethora of options:

And would you look at that: for the first time in a decade, we can actually manage Tags as well as Branches here! And we get to see all those commits and comments we’ve been making for years, all without having to use additional version control tools! It’s like Christmas has arrived early!

Here’s a WWDC video on how we’re meant to use the new features from now on. It certainly didn’t answer all the questions I had, so for that, read what I’ve learnt through experimentation further down. Continue reading