1. 将 MagicalRecord 文件夹拖入到工程文件中,引入 CoreData.frame 框架
![img](http://ww2.sinaimg.cn/mw690/78f9859egw1ey7fxzy0h3j20kx05dmxw.jpg)
2. 在 .pch 文件中引入头文件 CoreData+MagicalRecord.h4.
![img](http://ww4.sinaimg.cn/mw690/78f9859egw1ey7fy0aab0j20gq07nt9z.jpg)
3. 创建 Model.xcdatamodeld 文件,并创建一个 Teacher 的 ENTITIES,最后创建出 Teacher 类
在 Appdelete.m 文件中写以下代码
![img](http://ww4.sinaimg.cn/mw690/78f9859egw1ey7fy0rux7j20o80ewtcn.jpg)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[MagicalRecord setupCoreDataStackWithAutoMigratingSqliteStoreNamed:@"mobile.sqlite"];
Teacher * person = [Teacher MR_createEntity];
person.name = @"aaa";
[[NSManagedObjectContext MR_defaultContext]MR_saveToPersistentStoreAndWait];
NSLog(@"anme is %@",person.name);
return YES;
}