JLCoreDataHelper 0.2.2

JLCoreDataHelper 0.2.2

测试测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2016年3月

Joey Lee维护。



  • 作者:
  • Joey L.

安装

JLCoreDataHelper 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中

pod "JLCoreDataHelper"

开始之前

  1. 创建数据模型文件。(.xcdatamodeld)
  2. 按照您的要求设置实体和属性。
  3. 在应用启动时执行以下代码。推荐在 application:didFinishLaunchingWithOptions: 方法中执行此操作。
#import <JLCoreDataHelper/JLCoreDataHelper.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [JLCoreDataHelper initializeWithDataModelName:@"Data Model file name here" saveFolderName:@"folder name"]; 
}
  1. 可以选择将存储类型设置为特定的实体,如以下示例所示
[JLCoreDataHelper setStoreType:JLCoreDataStoreTypeMemory forEntity:@"Entity Name"];

使用说明

使用以下公开方法来管理数据。

#pragma mark -get
- (NSMutableArray *)getObjectsWithEntity:(NSString *)entityName;
- (NSMutableArray *)getObjectsWithCondition:(NSString *)condition
                                     entity:(NSString *)entityName;
- (NSMutableArray *)getObjectsWithCondition:(NSString *)condition
                                sortingKeys:(NSArray *)skeys
                                     entity:(NSString *)entityName;
- (NSMutableArray *)getObjectsWithCondition:(NSString *)condition
                                sortingKeys:(NSArray *)skeys
                                  ascending:(BOOL)ascending
                                     entity:(NSString *)entityName;

#pragma mark -set, update
- (id)set:(NSDictionary *)keyValue condition:(NSString *)condition entityName:(NSString *)entityName;
- (void)update:(NSDictionary *)keyValue condition:(NSString *)condition entityName:(NSString *)entityName;

#pragma mark -create
- (id)create:(NSDictionary *)newValue entityName:(NSString *)entityName;
- (id)createWithoutSaving:(NSDictionary *)newValue entityName:(NSString *)entityName;
- (id)createForEntityName:(NSString *)entityName initBlock:(void(^)(id newObject))initBlock;

#pragma mark -delete
- (BOOL)deleteObject:(id)object;
- (void)deleteAllObjectsForEntityName:(NSString *)entityName;

许可证

JLCoreDataHelper 在 MIT 许可下提供。有关更多信息,请参阅 LICENSE 文件。