Answer the question
In order to leave comments, you need to log in
Why does the code stop after deleting objects from Core Data?
TTNetworkDataSource* netSource = [TTNetworkDataSource sharedSource];
[netSource setContext:self];
TTDataSourceResponse* districtsResponse = [netSource requestDataWithQuery:@{@(OBJECT_TYPE): [HotlineDistrict clsName]}];
if (districtsResponse != nil) {
NSArray* objects = [self executeFetchRequestUnsafe:[NSFetchRequest fetchRequestWithEntityName:[HotlineDistrict clsName]] error:&localError];
NSInteger i = 0;
if (localError != nil) {
result = NO; return;
} else {
NSLog(@"%lu = fetchedObjects, %lu = districtsResponse", (unsigned long)objects.count, (unsigned long)districtsResponse.objects.count);
for (NSManagedObject* obj in objects) {
NSLog(@"Deleted Objects in fetched objects %ld", (unsigned long)i++);
[self deleteObject:obj];
}
for (NSManagedObject* obj in districtsResponse.objects) {
NSLog(@"Inserted Object in districtsResponse %ld", (unsigned long)i++);
[self insertObject:obj];
}
}
} else {
localError = [NSError errorInfo:@{NSLocalizedDescriptionKey: @"Error when getting districts."}];
result = NO;
}
TTDataSourceResponse* requestTypeResponse = [netSource requestDataWithQuery:@{@(OBJECT_TYPE): [HotlineRequestType clsName]}];
if (requestTypeResponse != nil) {
NSArray* objects = [self executeFetchRequestUnsafe:[NSFetchRequest fetchRequestWithEntityName:[HotlineRequestType clsName]] error:&localError];
NSInteger j = 0;
if (localError != nil) {
result = NO; return;
} else {
NSLog(@"%lu = fetchedObjects, %lu = requestTypeResponse", (unsigned long)objects.count, (unsigned long)requestTypeResponse.objects.count);
for (NSManagedObject* obj in objects) {
NSLog(@"Deleted Objects in fetched objects %ld", (unsigned long)j++);
[self deleteObject:obj];
}
for (NSManagedObject* obj in requestTypeResponse.objects) {
NSLog(@"Deleted Objects in requestTypeResponse %ld", (unsigned long)j++);
[self insertObject:obj];
}
}
} else {
localError = [NSError errorInfo:@{NSLocalizedDescriptionKey: @"Error when getting request types."}];
result = NO;
}
NSLog(@"%lu = fetchedObjects, %lu = districtsResponse", (unsigned long)objects.count, (unsigned long)districtsResponse.objects.count);
gives out:802 = fetchedObjects, 47 = districtsResponse
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question