0

I am trying to create a CoreData store with iCloud. Following the example code in iCloud Programming Guide for Core Data, I have this piece of code:

    NSPersistentStoreCoordinator *coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: salonbook.xcdatamodeld];

This is the image of my managed object model

enter image description here

I'm getting an error: Use of undeclared identifier 'salonbook'.

Why?

4

1 回答 1

0

您收到错误是因为您告诉它查找名为 的变量salonbook,该变量未声明。您需要在NSManagedObjectModel此处传递对实例的引用。通常这意味着您会使用self.managedObjectModel,但这实际上取决于您的其余代码。步骤必须是:

  1. NSManagedObjectModel从模型文件创建实例
  2. NSPersistentStoreCoordinator使用该模型对象创建一个。
于 2014-12-05T21:05:41.570 回答