Latest 0.0.3
Homepage https://github.com/HirokiUmatani/PEAR-CoreDataManager-iOS
License MIT
Platforms ios 7.0, requires ARC
Authors

PEAR-CoreDataManager-iOS GitHub license CocoaPods CocoaPods

====

Overview

This ios library can be to create and manage the CoreData.

Demo

autolayout_demo

Installation


pod 'PEAR-CoreDataManager-iOS'

Usage

[example]
Data model : CoreDataManager.xcdatamodeld
Entity model : CDTestEntity
attribute : type of Entity
id : integer64
num : integer64
name : String

  1. Create data model <.xcdatamodeld>
  2. Create entity model in data model
  3. Create attribute & type in entity model
  4. Create entity class <.h.m>

□ import header file

#import "CoreDataManager.h"

□ initialize

[CoreDataManager initSettingWithCoreDataName:@"CoreDataManager"
                                  sqliteName:@"CoreDataSqlite"];

□ insert

// create insert instance of CoreData
CDTestEntity *insertEntity = [CoreDataManager createInsertEntityWithClassName:@"CDTestEntity"];

// add value
insertEntity.num = @((uint)arc4random()%RAND_MAX);
insertEntity.name = @"test";

// save insert data
[CoreDataManager save];

□ update

// search condition
    NSPredicate *pred = [_coreDataManager setPredicateOverWithSearchKey:@"id" searchValue:@(0)];
    // fetch data
    [_coreDataManager fetchWithEntity:TEST_ENTITY
                            Predicate:pred
                              success:^(NSArray *fetchLists)
    {
        // update
        for (CDTestEntity *updateEntity in fetchLists)
        {
            updateEntity.name = @"update_test";
            [_coreDataManager save];
        }
    }
                               failed:^(NSError *error)
    {

    }];

□ fetch

// fetch all data
[CoreDataManager fetchWithEntity:@"CDTestEntity"
                       Predicate:nil
                         success:^(NSArray *fetchLists)
{
    // parse
    for (CDTestEntity *fetchEntity in fetchLists)
    {
         // access property of fetchEnity    
    }
}
                          failed:^(NSError *error)
{
}];

□ delete

[_coreDataManager fetchWithEntity:TEST_ENTITY
                            Predicate:nil
                              success:^(NSArray *fetchLists)
    {
        // delete entity
        for (CDTestEntity *deleteEntity in fetchLists)
        {
            [_coreDataManager deleteWithEntity:deleteEntity];
        }

    }
                               failed:^(NSError *error)
    {

    }];

Documents

library document

Licence

MIT

Author

GitHub
CocoaPod
FaceBook
Twitter

Latest podspec

{
    "name": "PEAR-CoreDataManager-iOS",
    "version": "0.0.3",
    "platforms": {
        "ios": "7.0"
    },
    "license": "MIT",
    "summary": "This ios library can be to create and manage the CoreData.",
    "homepage": "https://github.com/HirokiUmatani/PEAR-CoreDataManager-iOS",
    "authors": {
        "HirokiUmatani": "[email protected]"
    },
    "source": {
        "git": "https://github.com/HirokiUmatani/PEAR-CoreDataManager-iOS.git",
        "tag": "0.0.3"
    },
    "source_files": "PEAR-CoreDataManager-iOS/*.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This