Latest 0.1.4
License MIT
Platforms ios 7.0, requires ARC
Dependencies AFNetworking

[![CI Status]( Niazi/SnapIt.svg?style=flat)]( Niazi/SnapIt)


To run the example project, clone the repo, and run pod install from the Example directory first.

You must add "libsqlite3.dylib" to your "Linked Frameworks and Libraries" section of your application.

Persisting a SnapIt Resource.

SnapIt encapsulates the common patterns of persisting data to permanent storage via a SQLite Connection.

#import "SnapIt.h"
@interface Cat : SnapIt

To persist data, inherit from the SnapIt class.

SAVE method

Cat *mits = [[Cat alloc] init]; = @"Mits";
mits.color = @"orange";
[mits save];

To add an object to the database, modify it’s attributes and run the save method.

ALL method

NSArray *cats = [Cat all];

To retrieve all objects from the database, run the all method on the class you wish to query.

WHERE method

NSArray *people = [Person where:@"name='Beth'"];
Person *beth = people[0];

To retrieve an object from the database meeting a specific criteria, enter a where clause on the class in question with the where clause formatted as "object_property=value"

DELETE method

[lucy deleteSelf];

To delete an object from the database, run deleteSelf on the instance.

FETCH method

[beth fetch];

To update an object with it’s values in the database, run the fetch method on the instance. An example of when this is needed is after deleting an object with an association to the class. Run fetch to refresh it’s data.

BELONGS TO association

@property (strong, nonatomic) Person *person;

To set up a belongs to association, simply list a property in the header file with the class name. The name of the property must be the same as the class name, non pluralized. (i.e Cat => "cat")

Example Usage

Person *beth = [[Person alloc] init]; = @"Beth";
[beth save];

Cat *bubbles = [[Cat alloc] init]; = @"Bubbles";
bubbles.color = @"grey";
bubbles.person = beth;
[bubbles save];

bubbles.person => <Person: 0x7ff323f33a20>

HAS MANY association

@property (strong, nonatomic) NSArray *cats;

To set up a has many association, list an array property in the header file. The name of the property must be the same as the pluralized class name. (i.e Cat => "cats")

Example Usage

Person *beth = [[Person alloc] init];
NSArray *allCats = [Cat all];
beth.cats = allCats;
[beth save];

beth.cats => [
"<Cat: 0x7ff589f5ccc0>",
"<Cat: 0x7ff589f5d360>",
"<Cat: 0x7ff589f5dc70>",
"<Cat: 0x7ff589f5ead0>",
"<Cat: 0x7ff589f618a0>",
"<Cat: 0x7ff589f5f0f0>"



SnapIt is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "SnapIt"


Zak Niazi, [email protected]

Daniel Wu, [email protected]


SnapIt is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "SnapIt",
    "version": "0.1.4",
    "summary": "A Core Data Lite alternative built using Ruby like syntax.",
    "description": "                       * A Core Data Lite alternative for persistent storage of your objects. Use intuitive commands like "where" and "save" to fetch models or persist data. The syntax is based off of Active Record from Ruby on Rails.n",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "Zak Niazi": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.1.4"
    "platforms": {
        "ios": "7.0"
    "requires_arc": true,
    "source_files": "Pod/Classes/*.{h,m}",
    "resource_bundles": {
        "SnapIt": [
    "dependencies": {
        "AFNetworking": []

Pin It on Pinterest

Share This