NSManagedObjectModel initWithContentsOfURL returns nil eventhough the modelURL is valid

后端 未结 6 453
伪装坚强ぢ
伪装坚强ぢ 2021-01-01 13:42

my NSManagedObjectModel is returning nil eventhough the path is correct.

        NSString *modelKey = [NSString stringWithFormat:@\"/%@/Model\", name];
    N         


        
6条回答
  •  -上瘾入骨i
    2021-01-01 14:05

    I just encountered this issue after changing the case of the name of the .xcdatamodeld file (e.g. refactored "mydatastore.xcdatamodeld" to "MyDatastore.xcdatamodeld") on a case-insensitive filesystem.

    The fix includes both of the above answers:

    1. Refactor the data model file to a distinctly different name, e.g. "MyDatastoreTemporary.xcdatamodeld"

    2. Product > Clean

    3. Close XCode. Re-open XCode and the project.

    4. Refactor the data model file back to its final name, e.g. "MyDatastore.xcdatamodeld"

    5. Product > Clean

    6. Close XCode. Re-open XCode and the project.

提交回复
热议问题