Realm + JSON:调用createOrUpdateInRealm时的EXC BAD ACCESS:withJSONArray:第二次

时间:2016-01-12 03:25:37

标签: ios objective-c json xcode realm

+ (NSDictionary *)mc_inboundMapping {
static NSMutableDictionary *mappingForClassName = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
    mappingForClassName = [NSMutableDictionary dictionary];
});
@synchronized(mappingForClassName) {
    NSDictionary *mapping = mappingForClassName[[self className]];//<----EXC BAD ACCESS here
    if (!mapping) {
        SEL selector = NSSelectorFromString(@"JSONInboundMappingDictionary");
        if ([self respondsToSelector:selector]) {
            mapping = MCValueFromInvocation(self, selector);
        }
        else {
            mapping = [self mc_defaultInboundMapping];
        }
        mappingForClassName[[self className]] = mapping;
    }
    return mapping;
}

我在Realm中使用Realm+JSON。并且遇到了Realm+JSON的问题。 当我尝试多次createOrUpdateInRealm:withJSONArray:循环调用RLMObjects时,第一个RLMObject工作正常,但第二个RLMObject(无论是哪个类)都失败了{ {1}}关于静态变量。

我认为autorelease pool deallocate指向EXC BAD ACCESS code1。有人遇到过这个问题吗?我正在使用NSMutableDictionaryXCode 6.3.2

Realm 0.96.3

在这里打电话......

+ (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];
}

0 个答案:

没有答案