Category Archives: Windows

Passion Project: Mixing C++, Objective-C++, and Swift

I know a lot of folks have had to go through the process of bridging to C++ so you can use it from Objective-C or Swift. In my case I’m using it from Swift, so I thought I’d share what the middle Objective-C++ layer looks like. If you’ve done any Objective-C it will look like straight Objective-C, until you look a little closer. That’s when you’ll notice a C++ namespace, new, and delete statement. This code is a straight passthrough to the underlying C++ code — it’s here so Swift code can communicate with the C++ code.

Here’s the code that bridges to our Creatinine Clearance calculation.

https://gist.github.com/Fahrni/ed5c386bec659985b439306ac67cabd3

You’ll notice a class called PKMConvert that has a class method called genderFromPKMGender. I created a set of mirror enums. One on the iOS side the enums use NS_ENUM syntax, on the C++ side they’re straight C style enums, so this code converts between the two. It’s just a simple mapping.

Another thing you’ll notice is I’m still using “old” C++ syntax to create and destroy objects. I’ve been thinking about updating the syntax to C++11 so I’d use unique_ptr instead. We’ll see if that happens. It’s not a big deal.

Something I’ve been mulling over is releasing the entire PKMath C++ Library as an open source project once I have it working for iOS/Mac, Android, and Windows. I don’t know that it would be overly useful for anyone, but there you go.

Since I haven’t actually written any Swift code in the new RxCalc to use the Objective-C++ code I thought I’d share one of my unit tests for the Creatinine Clearance example above.

https://gist.github.com/Fahrni/423d34cc900679ff35f4bf99c9d0a778

Here’s how the different layers look from 30,000 feet. I like pictures, don’t you?rxcalc2layers

OneDrive flaw in Windows 10

Jerry Fahrni: “However, I can see all OneDrive content on each machine regardless of setting; file and folder names appear in online-only status. This all disappeared with the Windows 10 update. Now you have to pick which folders you wish to sync, and if you don’t sync them they don’t show up in your folder structure. That really ticks me off. That was the best feature of OneDrive. Without it there’s no reason to continue using it. Why would Microsoft remove such a useful feature? It defies logic.”

Jerry is not the only person disappointed with this change Paul Thurrott mention this flaw a few weeks back on Windows Weekly. hopefully Microsoft will follow up with a nice patch to repair this regression.

As a software developer we have to deal with tough choices like this to make sure we ship a stable product on time. As bad as this omission feels it was probably done for the sake of shipping. With Windows 10 the idea is to patch the OS often, as a service. We will see how well this plays out, but this feels like a good candidate for patching sooner rather than later.