Latest 0.3.3
License MIT
Platforms ios 7.0, requires ARC

[![CI Status]( Swanros/PTModel.svg?style=flat)]( Swanros/PTModel)

PTModel is a simple object store for persisting data on iOS applications.

When to use PTModel

Please note: this is in no way an attempt to replace CoreData. Its way far from that. If you’re looking for an alternative for CoreData, you may want to take a look at FCModel.

PTModel serves well when you only need to persist a set of data, without worrying too much about performance.

  1. Save some user configuration
  2. Persist data between app launches
  3. Some kind of cache, maybe?

PTModel is not designed to be a full-featured object graph. If what you need is save multiple entities, related to each other, what you want is to use CoreData.


To use PTModel, you just need to subclass it:

// Record.h
#import <PTModel/PTModel.h>

@interface Record : PTModel
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *band;

// Record.m
#import "Record.h"

@implementation Record

Saving objects

Record *newRecord = [Record new]; // Create a new object
newRecord.title = @"Divine Discontent"; = @"Sixpence None The Richer";

[newRecord save]; // Save your object to the store

Retrieving objects

In this version of PTModel you can retrieve objects by querying for them:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"title = %@", @"Divine Discontent"];
Record *retrievedRecord = [[Record instancesFilteredWithPredicate:predicate] firstObject];

Each instance of your subclass also has a guid property that is set right before the object is first saved. This is a unique ID, and you can use it to retrieve a specific object, too:

Record *favouriteRecord = [Record new];
favouriteRecord.title = @"Strangeland"; = @"Keane";

[favouriteRecord save]; // Here, the guid property is set on favouriteRecord

NSString *recordId = favouriteRecord.guid;
Record *recordToShare = [Record instanceWithId:recordId];

Updating an object

If you have an instance of your subclass of PTModel, you can simply modify one of its properties and call save on it to persist the changes.

// Using favouriteRecord from above...
favouriteRecord.title = @"Night Train";

[favouriteRecord save];

Deleting an object

You can call remove on your PTModel subclass instance to delete it from the store.

[favouriteRecord remove];

If you want to empty your whole store, you can call removeAllInstances on your subclass:

[Record removeAllInstances];


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

pod "PTModel"


Oscar Swanros @ Pacific3, [email protected]


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

Latest podspec

    "name": "PTModel",
    "version": "0.3.3",
    "summary": "PTModel is a simple object store for iOS apps.",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "Oscar Swanros @ Pacific3": "[email protected]"
    "source": {
        "git": "",
        "tag": "v0.3.3"
    "platforms": {
        "ios": "7.0"
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "resource_bundles": {
        "PTModel": [

Pin It on Pinterest

Share This