我在使用 Magical Record 时遇到问题。我有一组项目,它们ProviderSearchResult
是我需要导入的对象。当我导入它们时,我不断收到EXC_BAD_ACCESS
#24 0x00008770 in __67+[NSManagedObject(MagicalRecord) MR_executeFetchRequest:inContext:]_block_invoke at
MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalRecord.m:33
我已经到处搜索如何解决这个问题,但没有任何效果。我的代码是
ApiClient *client = [ApiClient sharedInstance];
NSDictionary *dataDictionary = [[NSDictionary alloc] initWithObjects:@[searchString] forKeys:@[@"companyName"]];
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dataDictionary options:0 error:&error];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSString *token = [[[UserManager sharedInstance] getAuthenticationObject] authenticationToken];
NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithObjects:@[@"json", token, jsonString ]
forKeys:@[@"callType", @"token", @"data"]];
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
[client getPath:@"GetClientInterfaces/" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
NSLog(@"Operation: %@", operation);
NSLog(@"Response: %@", responseObject);
NSLog(@"Type: %@", [[responseObject valueForKeyPath:@"details.items"] class]);
NSLog(@"First: %@", [[responseObject valueForKeyPath:@"details.items"] firstObject]);
NSArray *providerResults = [responseObject valueForKeyPath:@"details.items"];
NSLog(@"Results: %@", providerResults);
__block NSArray *array;
[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
array = [ProviderSearchResults MR_importFromArray:providerResults inContext:localContext];
}];
NSLog(@"Array: %@", array);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
NSLog(@"Operation: %@", operation);
NSLog(@"Shit: %@", error);
}];
任何人都可以看到任何会导致这不起作用的错误吗?