Nate Stedman


November 3rd, 2015

Rich-text formatting on iOS and OS X is performed with the NSAttributedString class. There are two components: a string value, and a set of substring ranges, each with an associated dictionary of attributes, which are a string key paired with an arbitrary value - since this is a Foundation class, these values must be of object types. These ranges cannot overlap. In a safe manner, attributed strings could be expressed as:

typealias AttributedString = [(Character, [String:AnyObject])]

API users do not need to interact with the backing representation at a low level, however - instead, attributes can be set across a range, or set for an entire string at initialization time. For example, given a mutable attributed string with a blue background color set across the entire string, adding a blue foreground color attribute to a middle range will automatically create three separate ranges: “blue background”, “blue background & red foreground”, and “blue background” again, each associated with the proper substring.

Read More

Carthage on Travis CI

November 1st, 2015

Carthage is a minimal dependency manager for Xcode projects. It’s currently not natively supported on Travis CI. Additionally, Carthage is currently written in Swift 1.2, which means that it can’t be built from source for projects using Xcode 7, which only supports Swift 2.

However, it’s easy to install from a binary:

curl -OlL ""
sudo installer -pkg "Carthage.pkg" -target /
rm "Carthage.pkg"

By running this as part of your Travis job, Carthage will be installed from a binary package. After that, you can bootstrap away. This is currently tied version 0.9.4 of Carthage, so the URL will have to be manually updated when the next version is released.