iOS:重命名项目后 NSBundle URLForResource 失败
我刚刚通过在项目导航器中缓慢双击项目蓝色横幅并修改值然后按 Enter 键来重命名我的 Xcode 4 项目。
重命名成功,项目编译、部署、运行成功。
有一个小问题。我想修改以下行中的字符串值以反映项目名称更改:
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"MyProjectName" withExtension:@"momd"];
当我将 @"MyProjectName"
更改为读取 @"MyNewProjectName"
时,应用程序崩溃因为从中检索到的值为零。
您指定的值在哪里查找?我已将 MyProjectName.xcdatamodeld
重命名为 MyNewProjectName.xcdatamodeld
但这没有帮助。我无法更新这个字符串,这让我很烦恼。
任何帮助将非常感激。
I've just renamed my Xcode 4 project by slowly double clicking on the project blue banner in the project navigator and modifying the value then pressing Enter.
The renaming was successful and the project compiles, deploys and runs successfully.
There is one minor problem. I would like to modify the string value in the following line to reflect the project name change:
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"MyProjectName" withExtension:@"momd"];
When I change the @"MyProjectName"
to read @"MyNewProjectName"
the app crashes since the retrieved value from this is nil.
Where is the value you specify being looked up? I've renamed the MyProjectName.xcdatamodeld
to be MyNewProjectName.xcdatamodeld
but that hasn't helped. It's bugging me that I can't update this string.
Any help would be very much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试从设备中删除应用程序和/或从模拟器中删除应用程序。重新编译并运行它。
Try deleting the app from the device and / or deleting the app from the simulator. Recompile and run it.