Skip to content
No description, website, or topics provided.
Objective-C Ruby
Branch: master
Clone or download
Latest commit 63908de Dec 30, 2015
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
CoreDataManager.xcodeproj version up Nov 15, 2015
CoreDataManager
CoreDataManagerTests
CoreDataManagerUITests add project file Nov 9, 2015
PEAR-CoreDataManager-iOS
LICENSE Initial commit Nov 9, 2015
PEAR-CoreDataManager-iOS.podspec version up 0.0.3 Nov 15, 2015
README.md

README.md

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

You can’t perform that action at this time.