Code-free
Code-free

Quick: Easy DispatchTime

Expressin' me some literals

Russ Bishop
November 10, 2016

Here's a quick bonus post. I find using DispatchTime a bit less convenient than it should be. In a GUI application I almost always just want to specify a TimeInterval, aka number of whole or fractional seconds.

Thankfully Swift extensions can grant my heart's desire:

extension DispatchTime: ExpressibleByIntegerLiteral { public init( . . .

Read More

Mixing Initializers

init? init! init throws

Russ Bishop
November 09, 2016

Today is a really simple post but something people struggle with, often in the context of extensions or interacting with RawRepresentable enums.

Can't delegate to failable initializer

Let's say you have a type with a failable initializer. Now you want to extend that type to support deserializing from JSON. You throw nice detailed . . .

Read More

The Technical Fraternity

Let's get real

Russ Bishop
October 13, 2016

When I read @RedQueenCoder's blog post... it really angried up my blood.

To all of you claiming knowledge of data structures is some kind of signal in interviews? Stop it.

Seriously.

It isn't reasonable to expect a candidate to derive that elegant solution it took two PhDs 8 months to discover.

Algorithm questions are not a way to . . .

Read More

Command Line Swift

#!/usr/bin/awesome

Russ Bishop
September 21, 2016

This post is mostly a brain dump of what it takes to use Swift for command line scripting.

Update: I've added -S to env. This makes things compatible with recent versions of FreeBSD. There doesn't appear to be a portable solution for Linux because it treats the entire line after the first space as a single argument rather than . . .

Read More

Inception

I came to remind you of what you once knew

Russ Bishop
September 09, 2016

Bar Ziony was asking about using type erasure to create a property that can contain any possible adopter of a protocol, but without using generics. I posted a gist but wanted to go over it in more detail, plus answer some follow-up questions.

Prerequisites

We'll start with a protocol and two types that adopt the protocol:

protocol  . . .

Read More

Apple File System

Ding

Russ Bishop
June 15, 2016

The Apple File System is still a slightly mysterious beast. Apple has reason to be cautious: A new file system is always a huge undertaking and the risks couldn't be higher: a serious bug can cause complete data loss.

AFPS is intended to replace CoreStorage, FileVault, and the iOS variants of HFS+. That's a lot of functionality!

. . .

Read More

Xcode Extensions

A brave new world

Russ Bishop
June 14, 2016

Xcode 8 now supports an official extension API. The first extension type supported is the Source Editor extension (though probably not the last). The flip-side is that Xcode 8 adopts System Integrity Protection. That means it is no longer possible to inject code into the Xcode process. Alcatraz is closed for business.

Basics of XcodeKit . . .

Read More

Archive
  Subscribe by Email and Never Miss a Post