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. PHP empty()函数使用需要注意

    在 PHP 5.5 之前,empty() 仅支持变量:任何其他东西将会导致一个解析错误.换言之,下列代码不会生效: empty(trim($name)). 作为替代,应该使用trim($name) = ...

  2. Codeforces510B【dfs】

    判断一个图里是否有一个自环: 50*50 标记起点,然后暴搜? #include <bits/stdc++.h> #include<algorithm> using names ...

  3. 黑客攻防技术宝典web实战篇:攻击其他用户习题

    猫宁!!! 参考链接:http://www.ituring.com.cn/book/885 随书答案. 1. 在应用程序的行为中,有什么“明显特征”可用于确定大多数 XSS 漏洞? 用户提交的输入在应 ...

  4. tyvj 1391 走廊泼水节【最小生成树】By cellur925

    题目传送门 题意简化:给你一棵树,要求你加边使它成为完全图(任意两点间均有一边相连) ,满足原来的树是这个图的最小生成树.求加边的价值最小是多少. 考虑Kruskal的过程,我们每次找一条最短的,两边 ...

  5. scikit-learning教程(二)统计学习科学数据处理的教程二

    模型选择:选择估计量及其参数 得分和交叉验证的分数 如我们所看到的,每个估计者都会公开一种score可以判断新数据的拟合质量(或预测)的方法.越大越好. >>> >>&g ...

  6. GCD Counting Codeforces - 990G

    https://www.luogu.org/problemnew/show/CF990G 耶,又一道好题被我浪费掉了,不会做.. 显然可以反演,在这之前只需对于每个i,统计出有多少(x,y),满足x到 ...

  7. Solutions to an Equation LightOJ - 1306

    Solutions to an Equation LightOJ - 1306 一个基础的扩展欧几里得算法的应用. 解方程ax+by=c时,基本就是先记录下a和b的符号fla和flb(a为正则fla为 ...

  8. input标签属性

    很多时候,我们都用到了很多标签实现输入功能,所以在这里梳理一下. 1.建立一个文本框 <input type="text" name="userName" ...

  9. 【Laravel】 常用命令

    自动创建项目 laravel new || laravel new xxx || composer create-project --prefer-dist laravel/laravel blog ...

  10. sass+compass起步

    前言:Sass is an extension of CSS that adds power and elegance to the basic language. It allows you to ...