One Quickie

Printable description from Swift thingies (Swift->General)
Tired of default output from your objects when doing a sanity-check print?

Just adopt CustomStringConvertible and implement description:

extension Weight: CustomStringConvertible {
    var description: String {
        return "(pounds) lbs"
If you're inheriting from NSObject, then you actually already have a description method, and will get an error to the tune of "redundant conformance of blah blah blah". In that case, you'd do this:
extension IndoorCyclingClass {
    override var description: String {
        return "(title) - (classDescription)"

borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book