Latest 0.0.5
License MIT
Platforms ios , requires ARC

Allows you to create objects from dictionaries and just handles a bunch of other annoying tasks. Inspired by code that I wrote while still at Sqwiggle. NSObject-OnSteroids is derieved from SQObject.{h,m} in the Sqwiggle iOS SDK


  • Rapidly map dictionary to object (helpful for dealing with dictionaries from REST APIs)
  • Export object to dictionary (helpful for when you are needed to post object to Rest APIs)
  • Encoding/Decoding for Coder baked right in.

How to Install

Add pod 'NSObject-OnSteroids' to your podfile, then import <NSObject-OnSteroids/NSObject-OnSteroids.h>. Sample code is available under subdirectory "NSObject-OnSteroidsExample".

How to Use

Create a new class that you’d like to map to. For this example, I’m going to create an object called "Book", and use the following code in .h and .m files, respectively:



#import <NSObject-OnSteroids/NSObject-OnSteroids.h>

@interface Book : NSObject

@property (nonatomic, retain) NSString *title;
@property (nonatomic, copy)   NSDictionary *someDictionary;

#import "Book.h"

@implementation Book

-(NSDictionary *)modelDefinition
    return @{@"title" : @"title", @"someDictionary": @"dictKey.importantDictionary"};


Swift (note: objects have to inheret NSObject. Sorry :-/. I’ll update this later)

//Objective-C Bridging Header
#import <NSObject-OnSteroids/NSObject-OnSteroids.h>
class Book : NSObject {
    override func modelDefinition() -> [NSObject : AnyObject]! {
        return ["title" : "title", "someDictionary" : "dictKey.importDictionary"]

You might be wondering… "WTF IS THAT MODEL DEFINITION CRAP?". It’s a method you need to override in this object so it knows which keys map to what property. The format for modelDefinition is

{"iOS Class Property" : "Dictionary KeyPath"}

Also make note of @"dictKey.importantDictionary". If the concept of KeyValuePath is fuzzy for you, basically adding the "." allows you to traverse a dictionary to get any childern. In this case, {dictKey": {"importantDictionary" : {"blah" : "blah"}}}

Now that we have the object all handled, let’s go ahead and import Book.h elsewhere and initialize a Book object:


#import "Book.h"


Book *book = [Book objectWithDictionary:@{@"title": @"How Now Brown Cow", @"dictKey" : @{@"importantDictionary" : @{@"blah" : @"hah"}}];
NSLog(@"Book Object: %@ ", book);
NSLog(@"Book Title: %@", book.title);
NSLog(@"Book Dictionary %@", book.someDictionary);


import Book


var Book : Book = Book(dictionary: ["title": "How Now Brown Cow", "dictKey" : ["importantDictionary" : ["blah" : "blah"]]])

println("Book Object: (book)")
println("Book Title: (book.title)")
println("Book Dictionary: (book.someDictionary)")

As you can now see, the given object has been mapped appropriately to each respective object. SWEET.

Let’s say I want to be able to get a dictionary format of the object I’ve just created. Simply do:


[book dictionaryFormat];



And you will be returned a dictionary of all properties and their respective values:

    dictKey = {"importantDictionary" : {"blah" : "hah"}};
    title = "How Now Brown Cow";

Sweet Jesus! Effectively removes the need for you to write any code to create a nicely formatted dictionary for posting, because it already knows what fields your API is using!


Open a GH Issue. Happy to discuss questions. This is still quite early and there’s a number of other ways I could go.


  • Tests!

Latest podspec

    "name": "NSObject-OnSteroids",
    "version": "0.0.5",
    "summary": "Allows you to create objects from dictionaries and just handles a bunch of other annoying tasks. Inspired by code in Sqwiggle for iOS SDK.",
    "homepage": "",
    "license": {
        "type": "MIT"
    "authors": {
        "Cameron Webb": ""
    "social_media_url": "",
    "platforms": {
        "ios": null
    "source": {
        "git": "",
        "tag": "0.0.5"
    "source_files": [
    "requires_arc": true

Pin It on Pinterest

Share This