Pretty Boolean

Let's just clear up that annoying busy value showing up as 0 or 1.

We will return to our Person class, and add a new computed property called busyString:

dynamic var name: String var busy: Bool dynamic var shirtColor: NSColor dynamic var busyString: String {     return busy ? "Busy" : "Not busy"     } 

We use the ternary operator to return a String representation of the Person object's busy state.

We have removed the dynamic keyword from the Busy property. This indicates that this property is not being used in Cocoa bindings. Should we need to access the Busy property for some other binding, we can put the dynamic keyword back, but it's a good practice to keep things tidied up as we progress.

We're not quite done yet; we need to ...

Get Mastering macOS Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.