gpt4 book ai didi

ios - 重命名 xcdatamodel 文件

转载 作者:IT王子 更新时间:2023-10-29 08:07:40 24 4
gpt4 key购买 nike

重命名 .xcdatamodel 文件需要做什么。重命名 .xcdatamodel 文件名,以及更改 ...

NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"newfilename" withExtension:@"momd"];
__managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
return __managedObjectModel;

NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"newfilename.sqlite"];

没用!我收到以下错误:

2011-04-11 17:19:54.164 ProjectName[5826:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot create an NSPersistentStoreCoordinator with a nil model'
*** Call stack at first throw:
(
0 CoreFoundation 0x00fa15a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x010f5313 objc_exception_throw + 44
2 CoreData 0x00013853 -[NSPersistentStoreCoordinator initWithManagedObjectModel:] + 419
3 ProjectName 0x00003471 -[ProjectNameAppDelegate persistentStoreCoordinator] + 257
4 ProjectName 0x000031a4 -[ProjectNameAppDelegate managedObjectContext] + 100
5 ProjectName 0x000028ca -[ProjectNameAppDelegate makeSplitViewController] + 762
6 ProjectName 0x00002d44 -[ProjectNameAppDelegate application:didFinishLaunchingWithOptions:] + 68
7 UIKit 0x001f3c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
8 UIKit 0x001f5d88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
9 UIKit 0x00200617 -[UIApplication handleEvent:withNewEvent:] + 1533
10 UIKit 0x001f8abf -[UIApplication sendEvent:] + 71
11 UIKit 0x001fdf2e _UIApplicationHandleEvent + 7576
12 GraphicsServices 0x018f9992 PurpleEventCallback + 1550
13 CoreFoundation 0x00f82944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
14 CoreFoundation 0x00ee2cf7 __CFRunLoopDoSource1 + 215
15 CoreFoundation 0x00edff83 __CFRunLoopRun + 979
16 CoreFoundation 0x00edf840 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x00edf761 CFRunLoopRunInMode + 97
18 UIKit 0x001f57d2 -[UIApplication _run] + 623
19 UIKit 0x00201c93 UIApplicationMain + 1160
20 ProjectName 0x00002599 main + 121
21 ProjectName 0x00002515 start + 53
)
terminate called after throwing an instance of 'NSException'

注意:我使用的是 Xcode4。

最佳答案

有一个名为 .xccurrentversion 的隐藏文件,它应该与您的 whatever.xcdatamodeld 文件位于同一位置。里面有对您的模型的引用,需要使用新名称进行更新。

在某些情况下,您必须从项目中删除 .xcdatamodeld 文件并重新添加它才能使其正常工作。

关于ios - 重命名 xcdatamodel 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5621178/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com