0
我正在看/做iTunes U斯坦福iPhone課程。 (免費提供!)。我正在試圖找出核心數據的狗仔隊計劃。CoreData幫助---如何調試?
下面是我如何將數據保存到coreData,我如何驗證這些信息實際上得到了保存?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
FlickrFetcher *ff = [FlickrFetcher sharedInstance];
if (![ff databaseExists])
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"FakeData" ofType:@"plist"];
NSArray *data = [NSArray arrayWithContentsOfFile: path];
NSManagedObjectContext *managedObjectContext = [ff managedObjectContext];
NSError *error = nil;
for (NSDictionary *row in data)
{
Person *person = (Person *)[NSEntityDescription insertNewObjectForEntityForName:@"Person" inManagedObjectContext:managedObjectContext];
Photo *photo = (Photo *)[NSEntityDescription insertNewObjectForEntityForName:@"Photo" inManagedObjectContext:managedObjectContext];
photo.name = [row objectForKey:@"name"];
photo.url = [row objectForKey:@"path"];
person.name = [row objectForKey:@"user"];
[person addPhotosObject:photo];
}
[managedObjectContext save:&error];
}
sqllite數據庫在哪裏? –
我在〜/ Library/Application Support/iPhone Simulator/4.3.2/Applications/UUID/Documents中找到它 –