Learn Courses My Dashboard

Aerokeith's iOS Journal

Hi! I just completed (and thoroughly enjoyed) the 14 Day Beginner Challenge (SwiftUI), and have now signed up for CWC+. I already have a moderate amount of software development experience (mostly C and a little C++), but I’m looking forward to learning about Swift/SwiftUI syntax and the associated iOS app programming paradigms.

I’m a sort-of-retired aerospace systems engineer, and a couple of years ago I started a 1-person company to develop LED lighting systems for large art installations, like those seen at Burning Man and Area 51 in Las Vegas. These systems are driven by a fairly powerful but very inexpensive microcontroller (sometimes several), using an Arduino-compatible software framework. Although there’s no real RTOS, my software supports cooperative multitasking and typically runs 20+ separate “tasks”. Lots of I/O.

I’ve been looking for an existing app that will allow me to use my iPhone as a wireless GUI to configure and control the artwork lighting, ideally using Bluetooth (BLE) as the interface. None of the existing apps meet all my needs, so I decided to buckle down and learn how develop my own. So far I’m optimistic that I’ll be able to produce something that’s “just right” for me, and maybe will also be useful to others developing similar types of embedded controllers.

Let’s go!

1 Like

I’ve started the iOS Foundations (SwiftUI) course, and just completed the Module 2 Lesson 2 Challenge (deck of cards). I managed to complete it without looking at the hints, but it wasn’t easy. I knew exactly what needed to be done, but I struggled with two things:

  1. Syntax for declaring an array of Structs, and properly instantiating the array members
  2. Figuring out that the deck structure needed to be made Equatable to enable searching/comparison

I finally arrived at the solution with a combination of Google searches, trial and error, and attempting to decipher the semi-cryptic Xcode error messages and suggestions. Whew!

Module 2 Lesson 12 (JSON Parsing)

I wasn’t totally clear on how the “key” part of a JSON element was used in the decoding process. I think I must have assumed that the decoding process was just based on the order and type of the JSON elements relative to the properties of the class that it was being decoded into.

Nope!

I inadvertently used “Name” in the JSON file, but the property in the Pizza class was called name. No output whatsoever, and not much clue about what went wrong (no error messages). As soon as I removed the capitalization, everything worked fine! So I guess the decoder actually compares the key name in the data file to the name of the property. To double-check this, I shuffled the order of the elements in the JSON file (swapped the order of “name” and “toppings”) and it still worked.

Based on my previous programming experience (mostly C), that seems very weird to correlate the contents of an “external” data file with a compile-time variable name. This makes it seem like the JSON decoding occurs when the code is compiled/built, instead of at “run time”. But that can’t be right, as it would make JSON decoding much less useful for the purpose of translating data from external feeds, etc. I’m guessing this point will be clarified in future lessons.

Thanks for sharing your story!

You’ll eventually most likely need to learn UIKit too (the predecessor to SwiftUI) to interact with Bluetooth.

But with what you’re learning now it’ll definitely help you in the long run!

Oh, that’s disappointing! Based on comments by Chris and others, I was hoping to avoid UIKit altogether.

Would you mind clarifying a bit? How is using Bluetooth dependent on the UI framework? Will I have to use UIKit for everything in that app, or is it possible to use SwiftUI for everything else?

Thanks!

Hi again! FYI, I happened to find this article, which appears to describe the development of an app using Core Bluetooth with SwiftUI.

Didn’t know this! Cool!