문제

I have this code:

for (Locality *loc in zona.locality){
NSFetchRequest *fetchLoc = [NSFetchRequest fetchRequestWithEntityName:@"Structure"];
            [fetchLoc setPredicate:[NSPredicate predicateWithFormat:@"locality.id_locality == %@", loc.id_locality]];
            fetchLoc.resultType = NSDictionaryResultType;
NSArray *resultsUpdate    = [context executeFetchRequest:fetchLoc
                                                           error:&error];
}

you can see that I use this code to get the Structure that have a particular id, and I do a fetchrequest that busy the system. So i want to know if is there a way to obtain only the number of the result, that is, only the number of Structure with the request id. And to know only one attribute of Structure (its id) and not all information. So that I want to speed up the request.

도움이 되었습니까?

해결책

Yes. You can add this:

[fetchLoc setPropertiesToFetch:@[@"structure_id"]];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top