资源简介
CoreData练习文件,对数据库的增删改查和对数据库的版本管理等....
代码片段和文件信息
//
// AppDelegate.m
// CoreDataProject
//
// Created by 代表月亮 on 13-12-5.
// Copyright (c) 2013年 lanou. All rights reserved.
//
#import “AppDelegate.h“
#import “Teacher.h“
#import “Student.h“
@implementation AppDelegate
@synthesize managedobjectContext = _managedobjectContext;
@synthesize managedobjectModel = _managedobjectModel;
@synthesize persistentStoreCoordinator = _persistentStoreCoordinator;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSString *docpath=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory NSUserDomainMask YES)lastobject];
NSLog(@“%@“docpath);
self.window = [[UIWindow alloc] initWithframe:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
//使用管理器类创建数据库
[self managedobjectContext];
//创建实体描述信息
/*NSEntityDescription *entityDescription=[NSEntityDescription entityForName:@“Teacher“ inManagedobjectContext:self.managedobjectContext];
// //获取数据管理器工具类帮忙创建的实体对象
Teacher *teacher=[[Teacher alloc]initWithEntity:entityDescription insertIntoManagedobjectContext:self.managedobjectContext];
//下面就可以对teacher中的所有属性进行修改
teacher.name=@“lichanghong“;
teacher.age=[NSNumber numberWithInteger:18];
NSLog(@“%@“teacher);
//将变化后的数据管理工具类保存
[self saveContext];
/*/
//获取数据库管理工具类中已经包含的对象
//1创建请求对象
NSFetchRequest *request=[NSFetchRequest fetchRequestWithEntityName:@“Teacher“];
//2执行请求对象获取请求结果
NSArray *teachers=[self.managedobjectContext executeFetchRequest:request error:nil];
NSLog(@“%@“teachers);
/*/删除第一条数据
[self.managedobjectContext deleteobject:teachers[0]];
[self saveContext];
*/
/*/创建学生实体描述信息
NSEntityDescription *studentDescription=[NSEntityDescription entityForName:@“Student“ inManagedobjectContext:self.managedobjectContext];
//获取学生实体的实例对象
Student *student=[[Student alloc]initWithEntity:studentDescription insertIntoManagedobjectContext:self.managedobjectContext];
student.name=@“lichanghong“;
[self saveContext];
//将学生对象添加到第一个entity实例对象内
// [firstEntity addStudentListobject:student];
[self saveContext];
*/
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 an
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-12-05 17:07 CoreDataProject\
文件 6148 2013-12-05 19:55 CoreDataProject\.DS_Store
目录 0 2013-12-05 19:55 __MACOSX\
目录 0 2013-12-05 19:55 __MACOSX\CoreDataProject\
文件 82 2013-12-05 19:55 __MACOSX\CoreDataProject\._.DS_Store
目录 0 2013-12-05 19:44 CoreDataProject\CoreDataProject\
文件 6148 2013-12-05 19:20 CoreDataProject\CoreDataProject\.DS_Store
目录 0 2013-12-05 19:55 __MACOSX\CoreDataProject\CoreDataProject\
文件 82 2013-12-05 19:20 __MACOSX\CoreDataProject\CoreDataProject\._.DS_Store
文件 614 2013-12-05 15:20 CoreDataProject\CoreDataProject\AppDelegate.h
文件 171 2013-12-05 15:20 __MACOSX\CoreDataProject\CoreDataProject\._AppDelegate.h
文件 8711 2013-12-05 19:44 CoreDataProject\CoreDataProject\AppDelegate.m
文件 171 2013-12-05 19:44 __MACOSX\CoreDataProject\CoreDataProject\._AppDelegate.m
文件 1161 2013-12-05 15:20 CoreDataProject\CoreDataProject\CoreDataProject-Info.plist
文件 378 2013-12-05 15:20 CoreDataProject\CoreDataProject\CoreDataProject-Prefix.pch
文件 171 2013-12-05 15:20 __MACOSX\CoreDataProject\CoreDataProject\._CoreDataProject-Prefix.pch
目录 0 2013-12-05 19:26 CoreDataProject\CoreDataProject\CoreDataProject.xcdatamodeld\
文件 270 2013-12-05 19:11 CoreDataProject\CoreDataProject\CoreDataProject.xcdatamodeld\.xccurrentversion
目录 0 2013-12-05 19:26 CoreDataProject\CoreDataProject\CoreDataProject.xcdatamodeld\CoreDataProject 2.xcdatamodel\
文件 1228 2013-12-05 19:26 CoreDataProject\CoreDataProject\CoreDataProject.xcdatamodeld\CoreDataProject 2.xcdatamodel\contents
目录 0 2013-12-05 18:52 CoreDataProject\CoreDataProject\CoreDataProject.xcdatamodeld\CoreDataProject.xcdatamodel\
文件 1018 2013-12-05 18:52 CoreDataProject\CoreDataProject\CoreDataProject.xcdatamodeld\CoreDataProject.xcdatamodel\contents
目录 0 2013-12-05 15:20 CoreDataProject\CoreDataProject\en.lproj\
文件 45 2013-12-05 15:20 CoreDataProject\CoreDataProject\en.lproj\InfoPlist.strings
目录 0 2013-12-05 19:55 __MACOSX\CoreDataProject\CoreDataProject\en.lproj\
文件 171 2013-12-05 15:20 __MACOSX\CoreDataProject\CoreDataProject\en.lproj\._InfoPlist.strings
目录 0 2013-12-05 15:20 CoreDataProject\CoreDataProject\Images.xcassets\
目录 0 2013-12-05 15:20 CoreDataProject\CoreDataProject\Images.xcassets\AppIcon.appiconset\
文件 333 2013-12-05 15:20 CoreDataProject\CoreDataProject\Images.xcassets\AppIcon.appiconset\Contents.json
目录 0 2013-12-05 19:55 __MACOSX\CoreDataProject\CoreDataProject\Images.xcassets\
目录 0 2013-12-05 19:55 __MACOSX\CoreDataProject\CoreDataProject\Images.xcassets\AppIcon.appiconset\
............此处省略33个文件信息
评论
共有 条评论