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:)
Swift
This is going to be a HUGE time saver!!!!
Now I can program my robot using Swift!!!! SwiftyGPIO
A Better RegularExpression
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
Scripting with Swift
Did you know that, just like Python, Bash scripts, etc., you can run a Swift source file right from the command-line as if it was an already compiled executable? You betcha! 😎 The Swift REPL program honors the SHEBANG line in a Swift source file. #!/usr/bin/swift import Foundation print("") print(" Int8 - size: \(MemoryLayout<Int8>.size); stride: … Continue reading Scripting with Swift
Avoiding a Swift NSRegularExpression Pitfall
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
Swift Property Wrappers
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
Fastest Way To Get The Time
So, for my 6502/6510 emulator project I've been trying to figure out the best (read that, "fastest") way to get the time with nanosecond resolution. I need this because the North American version of the Commodore 64 ran at 1.02MHz (1,022,727Hz) and so that means the clock "ticks" every 977.8 nanoseconds. And that's just for … Continue reading Fastest Way To Get The Time
Swift 5.3 for Raspberry Pi 4
Here is a build of Swift 5.3 for the Raspberry Pi 4 running Ubuntu Mate 20.04. See my post about the Odroid C2 for installation instructions. USE AT YOUR OWN RISK!!! I provide absolutely no warrantee with this at all! Swift 5.3 for the Raspberry Pi 4: https://www.dropbox.com/s/7l39d5df1zvbkm8/swift5.3-aarch64-rpi4-ubuntu-linux-20.04.tar.bz2?dl=0
Swift 5.3 on Odroid C2
As promised, here's the link to the build of Swift for the ODROID C2. This build was done on Ubuntu 20.04. Your results on other platforms/distros will most certainly vary. USE AT YOUR OWN RISK - I provide absolutely NO WARRANTY, implied or otherwise, with this what so ever. EDIT: 2020-09-22 - You will probably … Continue reading Swift 5.3 on Odroid C2
Swift on an Odroid C2
Over the weekend I managed to get a build of Swift working on the Odroid C2 SBC. As soon as I get a chance I'll TAR up the build and put it up on Dropbox. The build for the Raspberry Pi is still compiling. Here's the little sample program I wrote to test it out. … Continue reading Swift on an Odroid C2