Articles index

Stop the Swift

July 14 2020 by Jeff Johnson
Support this blog: Link Unshortener, StopTheMadness, Underpass, PayPal.Me

Many of the API pages in the Apple Developer Documentation have a language selector that allows you to choose whether to see the API in Swift or Objective-C. Swift is the default:

Language: Swift

The site used to remember your language selection, but lately it doesn't. This problem may have started with WWDC. If you still mainly write Objective-C code, you're forced to switch the language selection frequently from Swift to Objective-C, which isn't fun. Fortunately, I have a solution to this problem: a new browser extension called StopTheSwift, which you can download now! The extension works with Safari and also with any Chromium browser such as Google Chrome. It's very simplistic; here's the extension's JavaScript in entirety:

// Copyright (c) 2020 Jeffrey Johnson. All rights reserved.
(function() {
'use strict';
if (window === window.top && window.location.search === "" && window.location.href.startsWith("https://developer.apple.com/documentation/")) {
  window.location.search = "?language=objc";
}
})();

After you enable the extension, documentation pages will automatically load as Objective-C:

Language: Objective-C

I didn't feel like making a Firefox version of the extension, but you're free to borrow my JavaScript for private use, and if you want to distribute a Firefox extension publicly based on my code, just email me for permission.

Let the brackets be with you, always!

Support this blog: Link Unshortener, StopTheMadness, Underpass, PayPal.Me

Articles index