> I've created a Fetch Specification that uses qualifier variables. I am
> trying to set their values from the code and then fetch data.
> Documentation suggests to bind qualifier variables to elements of
> interface, but this is not what I want to do. I want to do everything in
> the code. Could anyone, please, help me out with this?
The source code for the EOUtilities category provides a good example of how
to do this. EOUtilities is implemented as a category on EOEditingContext
(for ObjC) in the EOAccess.framework, but the source code is available at
/Apple/Developer/Examples/EnterpriseObjects/Sources/EOUtilities.
Here's the method you're interested in:
- (NSArray *)objectsWithFetchSpecificationNamed:(NSString *)fetchSpecName
entityNamed:(NSString *)entityName
bindings:(NSDictionary *)bindings
{
EOModelGroup *modelGroup;
EOFetchSpecification *unboundFetchSpec;
EOFetchSpecification *boundFetchSpec;
NSArray *results;
modelGroup = [self modelGroup];
unboundFetchSpec = [modelGroup fetchSpecificationNamed:fetchSpecName
entityNamed:entityName];
if ( !unboundFetchSpec ) {
[NSException raise:NSObjectNotAvailableException
format:@"%@: Fetch specification '%@' not found in
entity named '%@'",
NSStringFromSelector(_cmd), fetchSpecName, entityName];
}
boundFetchSpec = [unboundFetchSpec
fetchSpecificationWithQualifierBindings:bindings];
results = [self objectsWithFetchSpecification:boundFetchSpec];
return results;
}
Good luck,
Craig