Within the Swift Foundation Library there exists a function called withoutActuallyEscaping(_:do:) that has, at least for me, become one of those hidden gems that is extremely useful for things beyond its original intention. As it's documentation states: Allows a nonescaping closure to temporarily be used as if it were allowed to escape.Apple Documentation - Swift … Continue reading Helpful Swift Trick #1 – withoutActuallyEscaping(_:do:)
Now I can program my robot using Swift!!!! SwiftyGPIO
As promised a while ago I've sat down and hammered out a better replacement for Swift's NSRegularExpression class. As I said then, NSRegularExpression is not actually a Swift class but rather an Objective-C class that has been bridged over to Swift via Swift's excellent ability to interface with C, C++, and Objective-C libraries directly. But … Continue reading A Better RegularExpression
Until Swift gets a native regular expression class of it's own we are stuck with the Objective-C version - NSRegularExpression. The Objective-C version is very capable and works very well but it's important to remember that it is working on Objective-C NSStrings which, unlike Swift's native Strings, are based on the UTF-16 encoding. What this … Continue reading Avoiding a Swift NSRegularExpression Pitfall
From now on with each new version of Swift that comes out I'm going to take some time a dig through all the Swift Evolution Proposals that made it into that release. Some real gems made it into the last few releases that I didn't know anything about but are really cool. The one I'm … Continue reading Swift Property Wrappers
I am really going to have to start playing around with the SwiftSyntax library! It looks like I'd be able to write some real code timesavers with it.
I've been having a tough time in Swift with the Struct vs. Class issue. Unlike Java and Objective-C, Swift allows value type "classes" known as Struct types. These behave very similar to C++ objects that are created without dynamic memory allocation - in other words they're created on the stack instead of the heap. This … Continue reading Swift Struct vs. Class
Here's just a little tidbit that I ran across recently where Xcode, which normally does a good job covering all the bases, fell short just a bit. When you're working with dynamic libraries in just about any environment, especially Linux and MacOS, there is a two-way street when it comes to a program or another … Continue reading Working with Dynamic Libraries in Xcode
The designers of Swift seem to have really odd opinions regarding the merits of certain patterns that are very common across other languages. For example, they have deemed that the prefix and postfix operators "++" and "--" are, for some reason, not desirable. Weird. 🧐 Not a biggie because they also built Swift with the … Continue reading Bringing Back Some Old Friends
Learning Swift is a lot easier thanks to Playgrounds!