سؤال

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