views:

587

answers:

0

In a previous question, I asked about how to filter out subentities from a Core Data fetch request on an array controller. The answer is to customize the fetch request used by the array controller. It seems I can easily do this in one of two ways. First, I could customize the fetch request in fetchWithRequest:merge:error:

- (BOOL)fetchWithRequest:(NSFetchRequest *)fetchRequest
                   merge:(BOOL)merge
                   error:(NSError **)error
{
    [fetchRequest setIncludesSubentities:NO];
    BOOL result = [super fetchWithRequest:fetchRequest merge:merge error:error];
    return result;
}

The second is to customize the fetch request returned from defaultFetchRequest:

- (NSFetchRequest *)defaultFetchRequest
{
    NSFetchRequest * fetchRequest = [super defaultFetchRequest];
    [fetchRequest setIncludesSubentities:NO];
    return fetchRequest;
}

Either way, I'm modifying an existing fetch request. One reservation I have with the first option is this bit from the API documentation on fetchWithRequest:merge:error:

This method performs a number of actions that you cannot reproduce. To customize this method, you should therefore create your own fetch request and then invoke super’s implementation with the new fetch request.

This seems to imply I should not modify the fetch request passed in. Should I make a copy and modify the copy before calling super instead? Does this same caveat also apply to overriding defaultFetchRequest, as well?