5
Khi đặt loại kết quả NSFetchRequest thành NSDictinaryResultType, không có đối tượng nào được trả về. Nếu tôi xóa setPropertiesToFetch và setResultType, tất cả các đối tượng được trả về.Dữ liệu chính NSFetchRequest setResultType: NSDictionaryResultType không hoạt động
Bất kỳ ý tưởng nào?
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Alert" inManagedObjectContext:_managedObjectContext];
[request setEntity:entity];
NSDictionary *entityProperties = [entity propertiesByName];
[request setPropertiesToFetch:[NSArray arrayWithObject:[entityProperties objectForKey:@"test"]]];
[request setResultType:NSDictionaryResultType];
NSError *error;
NSArray *result = [_managedObjectContext executeFetchRequest:request error:&error];
if (result == nil) {
NSLog(@"Error: %@", [error localizedDescription]);
}
Vâng, đây thực sự là một hình ảnh xác thực. Khi sử dụng NSDictionaryResultsType bạn không thể nhận được kết quả của các thay đổi đang chờ xử lý trên bối cảnh đối tượng được quản lý. – Aderstedt