My name is Jake Marsh.
I'm a developer, designer, and writer.

Subscribed via Push Notifications. You can also subscribe via RSS or Twitter.

Subscribe via RSS or Twitter.

Subscribe via Push Notifications, RSS or Twitter.

▸ Mantle: Objective-C Model Objects That Don't Suck!

The guys at Github have been rocking some awesome Objective-C open-source stuff lately, and their latest release, Mantle, does not disappoint.

Mantle makes it easy to write a simple model layer for your Cocoa or Cocoa Touch application.

Mantle has the potential (and already does) get rid of a ton of boilerplate model code. It provides default implementations of all the common <NSCoding> and <NSCopying> methods, as well as isEqual: and hash methods.

It also provides an awesome little method called mergeValuesForKeysFromModel:, which makes it easy to specify how new model data should be integrated.

My favorite feature though is how it cleanly utilizes reversible value transformers to allow for easy re-encoding back in to JSON at any time, not only that, but it even handles migration by automatically saving the version of the model object that was used for archival. Then, upon unarchiving, the migrateExternalRepresentation:fromVersion: method is invoked (only if migration is needed), giving you a convenient hook to upgrade old data.

Mantle is still in it's early days, but it looks quite promising.

You can read Github's blog post about Mantle here, and you can check out the Mantle Github repository right here.

Vote on Hacker News