在我的AppDelegate中没有定义managedObjectContext
我试图testing我的核心数据scheme。 但是,似乎我无法创build上下文,因为它表示No visible @interface for 'MyAppDelegate' declares the selector 'managedObjectContext'
。
在线教程中,当我们创build应用程序时,这个方法似乎是自动生成的。 但是,在我的情况下,它不存在。
这是MyAppDelegate:
头
#import <UIKit/UIKit.h> @interface MyAppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end
.m文件
#import "MyAppDelegate.h" @implementation MyAppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSManagedObjectContext *context = [self managedObjectContext]; // Override point for customization after application launch. return YES; }
我应该如何解决这个在iOS 7的Xcode 5?
我认为最好的办法是用Xcode 5创build一个Master-Detail Application
,不要忘记检查Use Core Data
:
有了这个,你将有一个AppDelegate.h
和一个AppDelegate.m
configuration一个managedObjectContext
。
您将拥有一个正确configuration了Core Data和.xcdatamodeld的项目,以便轻松使用您的SQLite数据库。