Ios 领域+;第二次调用createOrUpdateInRealm:withJSONArray:时,JSON:EXC访问错误
打电话到这里Ios 领域+;第二次调用createOrUpdateInRealm:withJSONArray:时,JSON:EXC访问错误,ios,objective-c,json,xcode,realm,Ios,Objective C,Json,Xcode,Realm,打电话到这里 + (NSArray *)createOrUpdateInRealm:(RLMRealm *)realm withJSONArray:(NSArray *)array { NSInteger count = array.count; NSMutableArray *result = [NSMutableArray array]; for (NSInteger index=0; index*kCreateBatchSize<count; index++) { NSIn
+ (NSArray *)createOrUpdateInRealm:(RLMRealm *)realm withJSONArray:(NSArray *)array {
NSInteger count = array.count;
NSMutableArray *result = [NSMutableArray array];
for (NSInteger index=0; index*kCreateBatchSize<count; index++) {
NSInteger size = MIN(kCreateBatchSize, count-index*kCreateBatchSize);
@autoreleasepool
{
for (NSInteger subIndex=0; subIndex<size; subIndex++) {
NSDictionary *dictionary = array[index*kCreateBatchSize+subIndex];
id object = [self createOrUpdateInRealm:realm withJSONDictionary:dictionary];
[result addObject:object];
}
}
}
return [result copy];
}
我想你只需要调用
createOrUpdateInRealm:withJSONArray:
1次?我的意思是在另一个RLMObject上第二次,所以每个RLMObject总是1次。你能不能发布你的代码,让我们看一看真正调用createOrUpdateInRealm:withJSONArray
?还有,你没有更新到0.97领域有什么原因吗?0.97需要XCode 7,所以,我现在不能。我将发布代码。谢谢我想我找到了问题(那是我的)。这个(R+J)是ARC项目,我的项目是非ARC项目。所以我不得不在构建阶段添加-fobjc arc标志。我想你只需要调用createOrUpdateInRealm:withJSONArray:
1次就可以了?我是说在另一个RLMObject上第二次,所以每个RLMObjects总是1次。你能发布你的代码,让我们看一下它实际上在调用createorupdateinrelm:withJSONArray
?还有,你没有更新到0.97领域有什么原因吗?0.97需要XCode 7,所以,我现在不能。我将发布代码。谢谢我想我找到了问题(那是我的)。这个(R+J)是ARC项目,我的项目是非ARC项目。所以我不得不在构建阶段添加-fobjc arc标志。
+ (NSArray *)createOrUpdateInRealm:(RLMRealm *)realm withJSONArray:(NSArray *)array {
NSInteger count = array.count;
NSMutableArray *result = [NSMutableArray array];
for (NSInteger index=0; index*kCreateBatchSize<count; index++) {
NSInteger size = MIN(kCreateBatchSize, count-index*kCreateBatchSize);
@autoreleasepool
{
for (NSInteger subIndex=0; subIndex<size; subIndex++) {
NSDictionary *dictionary = array[index*kCreateBatchSize+subIndex];
id object = [self createOrUpdateInRealm:realm withJSONDictionary:dictionary];
[result addObject:object];
}
}
}
return [result copy];
}
[realm beginWriteTransaction];
if ([collection isKindOfClass:[NSDictionary class]])
{
for (NSString *key in [collection allKeys])
{
NSLog(@"Set Data == %@:%@", key, collection[key]);
id jsData = [collection[key] objectForKey:@"data"];
if ([key isEqualToString:STATIC_ERROR_MSGS])
{
[SErrorMsgs createOrUpdateInRealm:realm withJSONArray:jsData];
}
else if ([key isEqualToString:STATIC_EPISODE])
{
[SEpisode createOrUpdateInRealm:realm withJSONArray:jsData];
}
else if ([key isEqualToString:STATIC_INGAME_TUTORIAL])
{
[SIngameTutorial createOrUpdateInRealm:realm withJSONArray:jsData];
} //more cases.........edited