我嘗試保存coredata許多對象,但得到這個崩潰:節約大量物體在coredata
Communications error: <OS_xpc_error: <error: 0x19b354af0> { count = 1, contents =
"XPCErrorDescription" => <string: 0x19b354e50> { length = 22, contents = "Connection interrupted" }
}>
Message from debugger: Terminated due to memory issue
我用MagicalRecord:
[MagicalRecord saveInBackgroundWithBlock:^(NSManagedObjectContext *localContext){
for (int i = 0; i < json.count; i++) {
[Product parseWithData:((NSMutableArray *)json)[i]];
}
}];
Product.m
+ (void)parseWithData:(NSDictionary *)dictionary {
NSString *xml_id = [dictionary[@"XML_ID"] isKindOfClass:[NSString class]] ? dictionary[@"XML_ID"] : @"";
Product *product = [Product getProductWithXML_id:xml_id];
if (!product)
product = [Product MR_createEntity];
product.xml_id = xml_id;
product.code = [dictionary[@"Code"] isKindOfClass:[NSString class]] ? dictionary[@"Code"] : @"";
...
}
你能建議我嗎,我該如何保存它?