如果运气好的话,我有点出局了。也许有人可以指出我正确的方向。我正在尝试使 MagicalRecord importFromObject 方法起作用。我所拥有的是:
- iOS SDK 5.1
- 基本 XCode iPhone 项目设置(空应用程序,无核心数据,ARQ)
- CoreData 框架手动添加到项目中
- 添加了带有一个实体的 coredata 数据模型
- 实体具有属性“标题”
Prefix.pch 包含以下内容:
#define MR_SHORTHAND
#import "CoreData+MagicalRecord.h"
此代码崩溃:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[MagicalRecord setupCoreDataStack];
[Product importFromObject:[NSDictionary dictionaryWithObject:@"test" forKey:@"title"]]; // Crashes here with EXC_BAD_ACCESS
....
}
它在此方法中在 NSManagedObject+MagicalRecord.m 中崩溃:
+ (NSArray *) MR_executeFetchRequest:(NSFetchRequest *)request inContext:(NSManagedObjectContext *)context
{
__block NSArray *results = nil;
[context performBlockAndWait:^{
NSError *error = nil;
results = [context executeFetchRequest:request error:&error]; // Crashes here with EXC_BAD_ACCESS
if (results == nil)
{
[MagicalRecord handleErrors:error];
}
}];
return results;
}