开发者

Changing the filename of a Core Data Managed Object Model

How do you change the filename 开发者_高级运维of a Core Data managed object model?

I would like to change the filename for the Core Data managed object model in my Xcode project. I am not concerned about any migration issues.

I currently access the file in my code this way:

    NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"Template" ofType:@"momd"];

I have not found a way to change the momd filename/package that does not result in Xcode failing to find the changed filename.


You have a hidden file .xcurrentversion inside the "model".xcdatamodeld.

Just edit this file to match your model's new name:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs$
<plist version="1.0">
<dict>
        <key>_XCCurrentVersionName</key>
        <!-- This name should be the same as the file name !-->
        <string>"model".xcdatamodel</string> 
</dict>
</plist>


Done that several times.

Simply rename the xcdmodel and take care of the name when you load it from the bundle. Before you run, make sure to clean the target. (Eg remove all precompiled files, else he think he did compile the model already and thus your app fails to load the momd since they are there with the wrong name)


Pretty sure this is the cause: http://openradar.appspot.com/7500956

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜