Core Data数据持久化是对SQLite的一个升级,它是ios集成的,在说Core Data之前,我们先说说在CoreData中使用的几个类。

(1)NSManagedObjectModel(被管理的对象模型)

相当于实体,不过它包含 了实体间的关系

(2)NSManagedObjectContext(被管理的对象上下文)

操作实际内容

作用:插入数据  查询  更新  删除

(3)NSPersistentStoreCoordinator(持久化存储助理)

相当于数据库的连接器

(4)NSFetchRequest(获取数据的请求)

相当于查询语句

(5)NSPredicate(相当于查询条件)

(6)NSEntityDescription(实体结构)

(7)后缀名为.xcdatamodel的包

里面的.xcdatamodel文件,用数据模型编辑器编辑

编译后为.momd或.mom文件,这就是为什么文件中没有这个东西,而我们的程序中用到这个东西而不会报错的原因

首先我们要建立模型对象

其次我们要生成模型对象的实体User,它是继承NSManagedObjectModel的

点击之后你会发现它会自动的生成User,现在主要说一下,生成的User对象是这种形式的

这里解释一下dynamic  平常我们接触的是synthesize

dynamic和synthesize有什么区别呢?它的setter和getter方法不能自已定义

打开CoreData的SQL语句输出开关

1.打开Product,点击EditScheme...
2.点击Arguments,在ArgumentsPassed On Launch中添加2项
1> -com.apple.CoreData.SQLDebug
2> 1

  1. #import <UIKit/UIKit.h>
  2. #import <CoreData/CoreData.h>
  3. @class ViewController;
  4. @interface AppDelegate : UIResponder <UIApplicationDelegate>
  5. @property (strong, nonatomic) UIWindow *window;
  6. @property (strong, nonatomic) ViewController *viewController;
  7. @property(strong,nonatomic,readonly)NSManagedObjectModel* managedObjectModel;
  8. @property(strong,nonatomic,readonly)NSManagedObjectContext* managedObjectContext;
  9. @property(strong,nonatomic,readonly)NSPersistentStoreCoordinator* persistentStoreCoordinator;
  10. @end
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
@class ViewController; @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) ViewController *viewController; @property(strong,nonatomic,readonly)NSManagedObjectModel* managedObjectModel; @property(strong,nonatomic,readonly)NSManagedObjectContext* managedObjectContext; @property(strong,nonatomic,readonly)NSPersistentStoreCoordinator* persistentStoreCoordinator;
@end
  1. #import "AppDelegate.h"
  2. #import "ViewController.h"
  3. @implementation AppDelegate
  4. @synthesize managedObjectModel=_managedObjectModel;
  5. @synthesize managedObjectContext=_managedObjectContext;
  6. @synthesize persistentStoreCoordinator=_persistentStoreCoordinator;
  7. - (void)dealloc
  8. {
  9. [_window release];
  10. [_viewController release];
  11. [_managedObjectContext release];
  12. [_managedObjectModel release];
  13. [_persistentStoreCoordinator release];
  14. [super dealloc];
  15. }
  16. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  17. {
  18. self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
  19. // Override point for customization after application launch.
  20. self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
  21. self.window.rootViewController = self.viewController;
  22. [self.window makeKeyAndVisible];
  23. return YES;
  24. }
  25. - (void)applicationWillResignActive:(UIApplication *)application
  26. {
  27. // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
  28. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
  29. }
  30. - (void)applicationDidEnterBackground:(UIApplication *)application
  31. {
  32. // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
  33. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
  34. }
  35. - (void)applicationWillEnterForeground:(UIApplication *)application
  36. {
  37. // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
  38. }
  39. - (void)applicationDidBecomeActive:(UIApplication *)application
  40. {
  41. // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
  42. }
  43. - (void)applicationWillTerminate:(UIApplication *)application
  44. {
  45. // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
  46. }
  47. //托管对象
  48. -(NSManagedObjectModel *)managedObjectModel
  49. {
  50. if (_managedObjectModel!=nil) {
  51. return _managedObjectModel;
  52. }
  53. //    NSURL* modelURL=[[NSBundle mainBundle] URLForResource:@"CoreDataExample" withExtension:@"momd"];
  54. //    _managedObjectModel=[[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
  55. _managedObjectModel=[[NSManagedObjectModel mergedModelFromBundles:nil] retain];
  56. return _managedObjectModel;
  57. }
  58. //托管对象上下文
  59. -(NSManagedObjectContext *)managedObjectContext
  60. {
  61. if (_managedObjectContext!=nil) {
  62. return _managedObjectContext;
  63. }
  64. NSPersistentStoreCoordinator* coordinator=[self persistentStoreCoordinator];
  65. if (coordinator!=nil) {
  66. _managedObjectContext=[[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];
  67. [_managedObjectContext setPersistentStoreCoordinator:coordinator];
  68. }
  69. return _managedObjectContext;
  70. }
  71. //持久化存储协调器
  72. -(NSPersistentStoreCoordinator *)persistentStoreCoordinator
  73. {
  74. if (_persistentStoreCoordinator!=nil) {
  75. return _persistentStoreCoordinator;
  76. }
  77. //    NSURL* storeURL=[[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"CoreaDataExample.CDBStore"];
  78. //    NSFileManager* fileManager=[NSFileManager defaultManager];
  79. //    if(![fileManager fileExistsAtPath:[storeURL path]])
  80. //    {
  81. //        NSURL* defaultStoreURL=[[NSBundle mainBundle] URLForResource:@"CoreDataExample" withExtension:@"CDBStore"];
  82. //        if (defaultStoreURL) {
  83. //            [fileManager copyItemAtURL:defaultStoreURL toURL:storeURL error:NULL];
  84. //        }
  85. //    }
  86. NSString* docs=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject];
  87. NSURL* storeURL=[NSURL fileURLWithPath:[docs stringByAppendingPathComponent:@"CoreDataExample.sqlite"]];
  88. NSLog(@"path is %@",storeURL);
  89. NSError* error=nil;
  90. _persistentStoreCoordinator=[[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
  91. if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {
  92. NSLog(@"Error: %@,%@",error,[error userInfo]);
  93. }
  94. return _persistentStoreCoordinator;
  95. }
  96. //-(NSURL *)applicationDocumentsDirectory
  97. //{
  98. //    return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
  99. //}
  100. @end
#import "AppDelegate.h"

#import "ViewController.h"

@implementation AppDelegate
@synthesize managedObjectModel=_managedObjectModel;
@synthesize managedObjectContext=_managedObjectContext;
@synthesize persistentStoreCoordinator=_persistentStoreCoordinator;
- (void)dealloc
{
[_window release];
[_viewController release];
[_managedObjectContext release];
[_managedObjectModel release];
[_persistentStoreCoordinator release];
[super dealloc];
} - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
} - (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
} - (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
} - (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
} - (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
} - (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
//托管对象
-(NSManagedObjectModel *)managedObjectModel
{
if (_managedObjectModel!=nil) {
return _managedObjectModel;
}
// NSURL* modelURL=[[NSBundle mainBundle] URLForResource:@"CoreDataExample" withExtension:@"momd"];
// _managedObjectModel=[[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
_managedObjectModel=[[NSManagedObjectModel mergedModelFromBundles:nil] retain];
return _managedObjectModel;
}
//托管对象上下文
-(NSManagedObjectContext *)managedObjectContext
{
if (_managedObjectContext!=nil) {
return _managedObjectContext;
} NSPersistentStoreCoordinator* coordinator=[self persistentStoreCoordinator];
if (coordinator!=nil) {
_managedObjectContext=[[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; [_managedObjectContext setPersistentStoreCoordinator:coordinator];
}
return _managedObjectContext;
}
//持久化存储协调器
-(NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if (_persistentStoreCoordinator!=nil) {
return _persistentStoreCoordinator;
}
// NSURL* storeURL=[[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"CoreaDataExample.CDBStore"];
// NSFileManager* fileManager=[NSFileManager defaultManager];
// if(![fileManager fileExistsAtPath:[storeURL path]])
// {
// NSURL* defaultStoreURL=[[NSBundle mainBundle] URLForResource:@"CoreDataExample" withExtension:@"CDBStore"];
// if (defaultStoreURL) {
// [fileManager copyItemAtURL:defaultStoreURL toURL:storeURL error:NULL];
// }
// }
NSString* docs=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject];
NSURL* storeURL=[NSURL fileURLWithPath:[docs stringByAppendingPathComponent:@"CoreDataExample.sqlite"]];
NSLog(@"path is %@",storeURL);
NSError* error=nil;
_persistentStoreCoordinator=[[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {
NSLog(@"Error: %@,%@",error,[error userInfo]);
}
return _persistentStoreCoordinator;
}
//-(NSURL *)applicationDocumentsDirectory
//{
// return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
//}
@end
  1. #import <UIKit/UIKit.h>
  2. #import "AppDelegate.h"
  3. @interface ViewController : UIViewController
  4. @property (retain, nonatomic) IBOutlet UITextField *nameText;
  5. @property (retain, nonatomic) IBOutlet UITextField *ageText;
  6. @property (retain, nonatomic) IBOutlet UITextField *sexText;
  7. @property(nonatomic,retain)AppDelegate* myAppDelegate;
  8. - (IBAction)addIntoDataSource:(id)sender;
  9. - (IBAction)query:(id)sender;
  10. - (IBAction)update:(id)sender;
  11. - (IBAction)del:(id)sender;
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
@interface ViewController : UIViewController
@property (retain, nonatomic) IBOutlet UITextField *nameText;
@property (retain, nonatomic) IBOutlet UITextField *ageText;
@property (retain, nonatomic) IBOutlet UITextField *sexText;
@property(nonatomic,retain)AppDelegate* myAppDelegate;
- (IBAction)addIntoDataSource:(id)sender;
- (IBAction)query:(id)sender;
- (IBAction)update:(id)sender;
- (IBAction)del:(id)sender;
  1. #import "ViewController.h"
  2. #import "User.h"
  3. @interface ViewController ()
  4. @end
  5. @implementation ViewController
  6. - (void)viewDidLoad
  7. {
  8. [super viewDidLoad];
  9. // Do any additional setup after loading the view, typically from a nib.
  10. _myAppDelegate=(AppDelegate *)[[UIApplication sharedApplication] delegate];
  11. }
  12. - (void)didReceiveMemoryWarning
  13. {
  14. [super didReceiveMemoryWarning];
  15. // Dispose of any resources that can be recreated.
  16. }
  17. - (void)dealloc {
  18. [_nameText release];
  19. [_ageText release];
  20. [_sexText release];
  21. [super dealloc];
  22. }
  23. //插入数据
  24. - (IBAction)addIntoDataSource:(id)sender {
  25. User* user=(User *)[NSEntityDescription insertNewObjectForEntityForName:@"User" inManagedObjectContext:self.myAppDelegate.managedObjectContext];
  26. [user setName:_nameText.text];
  27. [user setAge:[NSNumber numberWithInteger:[_ageText.text integerValue]]];
  28. [user setSex:_sexText.text];
  29. NSError* error;
  30. BOOL isSaveSuccess=[_myAppDelegate.managedObjectContext save:&error];
  31. if (!isSaveSuccess) {
  32. NSLog(@"Error:%@",error);
  33. }else{
  34. NSLog(@"Save successful!");
  35. }
  36. }
  37. //查询
  38. - (IBAction)query:(id)sender {
  39. NSFetchRequest* request=[[NSFetchRequest alloc] init];
  40. NSEntityDescription* user=[NSEntityDescription entityForName:@"User" inManagedObjectContext:_myAppDelegate.managedObjectContext];
  41. [request setEntity:user];
  42. //    NSSortDescriptor* sortDescriptor=[[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
  43. //    NSArray* sortDescriptions=[[NSArray alloc] initWithObjects:sortDescriptor, nil];
  44. //    [request setSortDescriptors:sortDescriptions];
  45. //    [sortDescriptions release];
  46. //    [sortDescriptor release];
  47. NSError* error=nil;
  48. NSMutableArray* mutableFetchResult=[[_myAppDelegate.managedObjectContext executeFetchRequest:request error:&error] mutableCopy];
  49. if (mutableFetchResult==nil) {
  50. NSLog(@"Error:%@",error);
  51. }
  52. NSLog(@"The count of entry: %i",[mutableFetchResult count]);
  53. for (User* user in mutableFetchResult) {
  54. NSLog(@"name:%@----age:%@------sex:%@",user.name,user.age,user.sex);
  55. }
  56. [mutableFetchResult release];
  57. [request release];
  58. }
  59. //更新
  60. - (IBAction)update:(id)sender {
  61. NSFetchRequest* request=[[NSFetchRequest alloc] init];
  62. NSEntityDescription* user=[NSEntityDescription entityForName:@"User" inManagedObjectContext:_myAppDelegate.managedObjectContext];
  63. [request setEntity:user];
  64. //查询条件
  65. NSPredicate* predicate=[NSPredicate predicateWithFormat:@"name==%@",@"chen"];
  66. [request setPredicate:predicate];
  67. NSError* error=nil;
  68. NSMutableArray* mutableFetchResult=[[_myAppDelegate.managedObjectContext executeFetchRequest:request error:&error] mutableCopy];
  69. if (mutableFetchResult==nil) {
  70. NSLog(@"Error:%@",error);
  71. }
  72. NSLog(@"The count of entry: %i",[mutableFetchResult count]);
  73. //更新age后要进行保存,否则没更新
  74. for (User* user in mutableFetchResult) {
  75. [user setAge:[NSNumber numberWithInt:12]];
  76. }
  77. [_myAppDelegate.managedObjectContext save:&error];
  78. [mutableFetchResult release];
  79. [request release];
  80. }
  81. //删除
  82. - (IBAction)del:(id)sender {
  83. NSFetchRequest* request=[[NSFetchRequest alloc] init];
  84. NSEntityDescription* user=[NSEntityDescription entityForName:@"User" inManagedObjectContext:_myAppDelegate.managedObjectContext];
  85. [request setEntity:user];
  86. NSPredicate* predicate=[NSPredicate predicateWithFormat:@"name==%@",@"chen"];
  87. [request setPredicate:predicate];
  88. NSError* error=nil;
  89. NSMutableArray* mutableFetchResult=[[_myAppDelegate.managedObjectContext executeFetchRequest:request error:&error] mutableCopy];
  90. if (mutableFetchResult==nil) {
  91. NSLog(@"Error:%@",error);
  92. }
  93. NSLog(@"The count of entry: %i",[mutableFetchResult count]);
  94. for (User* user in mutableFetchResult) {
  95. [_myAppDelegate.managedObjectContext deleteObject:user];
  96. }
  97. if ([_myAppDelegate.managedObjectContext save:&error]) {
  98. NSLog(@"Error:%@,%@",error,[error userInfo]);
  99. }
  100. }
  101. @end
#import "ViewController.h"
#import "User.h"
@interface ViewController () @end @implementation ViewController - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_myAppDelegate=(AppDelegate *)[[UIApplication sharedApplication] delegate];
} - (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} - (void)dealloc {
[_nameText release];
[_ageText release];
[_sexText release];
[super dealloc];
}
//插入数据
- (IBAction)addIntoDataSource:(id)sender {
User* user=(User *)[NSEntityDescription insertNewObjectForEntityForName:@"User" inManagedObjectContext:self.myAppDelegate.managedObjectContext];
[user setName:_nameText.text];
[user setAge:[NSNumber numberWithInteger:[_ageText.text integerValue]]];
[user setSex:_sexText.text];
NSError* error;
BOOL isSaveSuccess=[_myAppDelegate.managedObjectContext save:&error];
if (!isSaveSuccess) {
NSLog(@"Error:%@",error);
}else{
NSLog(@"Save successful!");
} }
//查询
- (IBAction)query:(id)sender {
NSFetchRequest* request=[[NSFetchRequest alloc] init];
NSEntityDescription* user=[NSEntityDescription entityForName:@"User" inManagedObjectContext:_myAppDelegate.managedObjectContext];
[request setEntity:user];
// NSSortDescriptor* sortDescriptor=[[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
// NSArray* sortDescriptions=[[NSArray alloc] initWithObjects:sortDescriptor, nil];
// [request setSortDescriptors:sortDescriptions];
// [sortDescriptions release];
// [sortDescriptor release];
NSError* error=nil;
NSMutableArray* mutableFetchResult=[[_myAppDelegate.managedObjectContext executeFetchRequest:request error:&error] mutableCopy];
if (mutableFetchResult==nil) {
NSLog(@"Error:%@",error);
}
NSLog(@"The count of entry: %i",[mutableFetchResult count]);
for (User* user in mutableFetchResult) {
NSLog(@"name:%@----age:%@------sex:%@",user.name,user.age,user.sex);
}
[mutableFetchResult release];
[request release];
}
//更新
- (IBAction)update:(id)sender {
NSFetchRequest* request=[[NSFetchRequest alloc] init];
NSEntityDescription* user=[NSEntityDescription entityForName:@"User" inManagedObjectContext:_myAppDelegate.managedObjectContext];
[request setEntity:user];
//查询条件
NSPredicate* predicate=[NSPredicate predicateWithFormat:@"name==%@",@"chen"];
[request setPredicate:predicate];
NSError* error=nil;
NSMutableArray* mutableFetchResult=[[_myAppDelegate.managedObjectContext executeFetchRequest:request error:&error] mutableCopy];
if (mutableFetchResult==nil) {
NSLog(@"Error:%@",error);
}
NSLog(@"The count of entry: %i",[mutableFetchResult count]);
//更新age后要进行保存,否则没更新
for (User* user in mutableFetchResult) {
[user setAge:[NSNumber numberWithInt:12]]; }
[_myAppDelegate.managedObjectContext save:&error];
[mutableFetchResult release];
[request release]; }
//删除
- (IBAction)del:(id)sender {
NSFetchRequest* request=[[NSFetchRequest alloc] init];
NSEntityDescription* user=[NSEntityDescription entityForName:@"User" inManagedObjectContext:_myAppDelegate.managedObjectContext];
[request setEntity:user];
NSPredicate* predicate=[NSPredicate predicateWithFormat:@"name==%@",@"chen"];
[request setPredicate:predicate];
NSError* error=nil;
NSMutableArray* mutableFetchResult=[[_myAppDelegate.managedObjectContext executeFetchRequest:request error:&error] mutableCopy];
if (mutableFetchResult==nil) {
NSLog(@"Error:%@",error);
}
NSLog(@"The count of entry: %i",[mutableFetchResult count]);
for (User* user in mutableFetchResult) {
[_myAppDelegate.managedObjectContext deleteObject:user];
} if ([_myAppDelegate.managedObjectContext save:&error]) {
NSLog(@"Error:%@,%@",error,[error userInfo]);
}
}
@end

对于多线程它是不安全的,需要进行特殊处理下次再说吧

ios之coredata的更多相关文章

  1. IOS中CoreData浅析

    CoreData简介: 什么是CoreData? Core Data是iOS5之后才出现的一个框架,它提供了对象-关系映射(ORM)的功能,即能够将OC对象转化成数据,保存在SQLite数据库文件中, ...

  2. iOS 让CoreData更简单些

    原文:http://www.cocoachina.com/ios/20170421/19096.html 前言 本文并不是CoreData从入门到精通之类的教程, 并不会涉及到过多的原理概念描述, 而 ...

  3. Step by Step Do IOS Swift CoreData Simple Demo

    简单介绍 这篇文章记录了在 IOS 中使用 Swift 操作 CoreData 的一些基础性内容,因为缺乏文档,基本上都是自行实验的结果.错漏不可避免,还请谅解. 部分内容借鉴了 Tim Roadle ...

  4. iOS开发CoreData的简单使用

    1.简介 CoreData是iOS5后,苹果提供的原生的用于对象化管理数据并且持久化的框架.iOS10苹果对CoreData进一步进行了封装,而且效率更高!相关类的简单介绍: NSManagedObj ...

  5. iOS 中CoreData的简单使用

    原文链接:http://www.jianshu.com/p/4411f507dd9f 介绍:本文介绍的CoreData不在AppDelegate中创建,在程序中新建工程使用,即创建本地数据库,缓存数据 ...

  6. ios中coredata

    http://blog.csdn.net/q199109106q/article/details/8563438 // // MJViewController.m // 数据存储5-Core Data ...

  7. iOS中coreData的用法

    // // ViewController.m // coredatademo002 // // Created by ganchaobo on 13-6-29. // Copyright (c) 20 ...

  8. iOS:CoreData数据库的使用二(创建多个数据库表,表之间有对应关系)

    CoreData数据库框架是一个封装性好,功能强大数据库,它底层使用的还是sqlite数据库,不过苹果公司在其基础上,为其封装新和安全性的维护上做了大量的处理,例如对一些事物做了详细的操作,如读脏数据 ...

  9. iOS: 转载CoreData数据库框架

    iphone-CoreData的使用详解 一.概念 1.Core Data 是数据持久化存储的最佳方式 2.数据最终的存储类型可以是:SQLite数据库,XML,二进制,内存里,或自定义数据类型 在M ...

随机推荐

  1. 洛谷 - P1012 - 拼数 - 排序

    https://www.luogu.org/problemnew/show/P1012 这道水题居然翻车了,还发现不了bug,服气了.并不是空字符一定比不空要好,要取决于替代它的字符的大小.所以还是直 ...

  2. bzoj 2927: [Poi1999]多边形之战【博弈论】

    先手必胜状态是黑三角在边上 然后其他情况脑补一下,n为偶数先手必胜,可以理解为从某一边取,先手总有办法让后手取得一边有奇数个 #include<iostream> #include< ...

  3. Magic Numbers CodeForces - 628D

    Magic Numbers CodeForces - 628D dp函数中:pos表示当前处理到从前向后的第i位(从1开始编号),remain表示处理到当前位为止共产生了除以m的余数remain. 不 ...

  4. 当css样式表遇到层

    (附:White-space:pre可以是样式表里卖弄body的属性,作用是保持html源代码的空格与换行,等同<pre>标签.) Css样式表可以通过被封在层里的方式来限制页面所修饰的内 ...

  5. SecureCRT的配色方法

    配色后效果如下: 下面开始配色 1.首先配置成默认模式 2.终端(Terminal)==>仿真(Emulation) 按图中标注进行勾选,勾选完毕点击确认 2.选项(Options)==> ...

  6. CentOS 6.9:MySQL Daemon failed to start.

    [root@Server_1 12:02:58 ~ 25]#service mysqld start MySQL Daemon failed to start.Starting mysqld: [ro ...

  7. php数组与字符串转换

    1.将字符串转换成数组的几个函数: (1)explode(separate,string) 示例:$str = "Hello world It's a beautiful day" ...

  8. Hacker的社交礼仪与自我修养【转】

    Hacker School是位于纽约的一所特殊的编程“学校”,他们的目标是帮助参与者变成“更好的程序员”,之所以说他们特殊是因为这所“学校”没有老师,没有考试,也不会颁发证书,他们信奉三人行必有我师, ...

  9. oracle 数据导入、导出

    导入导出 --数据导出备份和导入 ------注意 导出和导入 必须是CMD 命令行下操作,而不是SQL编辑器中 --1.导出表 . --exp:导出关键字 ,userid:用户权限 ,file:保存 ...

  10. Clean Code 第十章 : 类

    最近的CleanCode读到了第十章.这一张主要讲了如何去构造一个类,感觉的CleanCode至此已经不仅仅是单纯的讲如何'写'出漂亮的代码,而是从设计方向上去构造出好的代码了. 本章节主要讲了: * ...