MagicalRecord操作CoreData小示例
来源:互联网 发布:在手机淘宝怎么卖东西 编辑:程序博客网 时间:2024/06/04 19:46
自我感觉方便许多
- (void)viewDidLoad {
[superviewDidLoad];
// 查询
[selfselectAction];
// 更新
// [self updateAction];
// 删除
[selfdeleteAction];
// 查询
[selfselectAction];
}
-(void)insertAction
{
Person * per = [PersonMR_createEntity];
per.name = @"zhangsan";
per.age = @12;
[[NSManagedObjectContextMR_defaultContext] MR_saveToPersistentStoreAndWait];
}
-(void)deleteAction
{
NSArray *persons = [PersonMR_findAll];
Person * per = persons[0];
// 删除实体
[per MR_deleteEntity];
// 保存此变化
[[NSManagedObjectContextMR_defaultContext] MR_saveToPersistentStoreAndWait];
}
-(void)updateAction
{
//查找数据库中的所有Person。
NSArray *persons = [PersonMR_findAll];
Person * per = persons[0];
per.name = @"lisi";
per.age = @80;
[[NSManagedObjectContextMR_defaultContext] MR_saveToPersistentStoreAndWait];
}
-(void)selectAction
{
//查找数据库中的所有Person。
NSArray *persons = [PersonMR_findAll];
NSLog(@"%ld", persons.count);
for(Person * perin persons){
NSLog(@"name = %@,age = %@", per.name, per.age);
}
}
- MagicalRecord操作CoreData小示例
- 使用MagicalRecord操作CoreData
- 使用开源库 MagicalRecord 操作 CoreData
- 使用开源库 MagicalRecord 操作 CoreData
- 使用开源库 MagicalRecord 操作 CoreData
- CoreData-MagicalRecord
- CoreData小示例
- MagicalRecord,一个简化CoreData操作的工具库
- Using CoreData with MagicalRecord
- CoreData+MagicalRecord的使用
- CoreData和管理者MagicalRecord
- CoreData之MagicalRecord源码解读
- CoreData第三方数据---MagicalRecord使用说明
- CoreData封装类MagicalRecord的使用
- iOS coreData和MagicalRecord如何分页
- iOS数据存储之CoreData封装MagicalRecord
- 数据持久化(六)之Using CoreData with MagicalRecord
- CoreData的使用之三:MagicalRecord第三方库
- 对java List中的对象进行排序
- Android Studio很实用的调试技巧
- perl lwp 响应信息
- SNMP 原理与实战详解
- RecyclerView , IllegalStateException: Cannot call this method while RecyclerView is computing a layo
- MagicalRecord操作CoreData小示例
- 视频编码名词参数解释
- 学习Android从0开始之开发工具篇-Android studio详解
- 挤死collideWith: function(other, axis) { if (other.touches(this)) { other.kill(); } }
- 主程序访问线程的临时变量
- Android Studio导入eclipse项目
- LIO -SCSI target
- SQLite
- 字符串截取和替换