Categories
iOS Nerd Sniped Swift

UITextView, autocorrect, and custom attributes

For this week’s “Nerd Snipe”, I spent way too much time at work trying to track down a pesky bug related to our editor. Long story short, we send some custom NSAttributedString.Keys to signify differences in rich text. For instance, a heading attribute with an integer value may tell a parser to wrap text in an <h2> when converting the string to HTML.

Oddly, sometimes that special attribute wouldn’t be included when text was autocorrected, so the generated HTML wasn’t always what we expected. After a lot of digging I believe this could be a bug in UITextView (or maybe NSTextStorage).

Inspecting the value of attrString in the NSTextStorage function func replaceCharacters(in range: NSRange, with attrString: NSAttributedString) after autocorrecting some text shows that it only seems to include attributes that were defined in Foundation (e.g. NSFont, etc.), but not our custom ones.

Regular typing works fine – you see all the expected attributes set in textView.typingAttributes.

In scenarios like these I like to make the simplest example to help confirm I understand it, so I’ve made a repo demonstrating the issue in case it’s helpful for anyone.

Categories
Arduino Troubleshooting Windows

Arduino Leonardo, VirtualBox, and Windows

I realize this post may be useful to about three other people in the world, but sharing is caring.

What I wanted to do

On my Windows 11 machine I wanted to be able to write and upload firmware to an Arduino Pro Micro (Leonardo) using PlatformIO.

The standard way to accomplish this is to install PlatformIO in VSCode for Windows and you’re done. However, I’m a bit of long time *nix user and really like my PlatformIO + Git workflow in that environment.

WSL sounds like a great option for this case, but unfortunately from what I’ve read, serial communication doesn’t play too nicely without a bunch of hoops to jump through.

To keep things (somewhat) simple I installed a Linux VM through VirtualBox and added a USB Device Filter for the attached Arduino Leonardo so it would be forwarded and accessible by PlatformIO. Using VSCode as my editor would still be possible thanks to its awesome remote features.

Categories
iOS Projects Thoughts

Happy New Year!

Categories
Thoughts

Watch your tabs!

Yay computers!

Because I missed a tab in a Python script, my home Docker box has been running with a higher-than-necessary CPU utilization and spiky temperatures for five months. 😬

Tab has now been tabbed. 🐍

Categories
Projects Raspberry Pi

Snake Eyes + Servos

Categories
Fun

Carve Different

A pumpkin with the Apple logo carved in it.
Categories
Swift SwiftUI

Squishy buttons!

Categories
Swift SwiftUI

Faux Notch Fun

I’ve seen a lot of these little “fake notch” apps pop up since Apple’s new MacBooks were announced, but I didn’t see a lot of source code – so of course I was nerd sniped.

Here’s a basic example of making one using AppKit and SwiftUI!

Categories
iOS Projects Swift SwiftUI

Wyze Cam in iOS

Categories
News

Joining Automattic

I’m thrilled to be joining the fine folks at Automattic this month as a mobile software engineer. Though I’ll miss all of my wonderful Clemson coworkers immensely, I’m excited for the road ahead. 🚀