Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

predicateWithBlock: passes NSDictionaryMapNode

Sometimes, when I try to use an NSPredicate with an NSFetchRequest, the evaluatedObject it passes to the block is either nil or an instance of NSDictionaryMapNode, which nobody ever seems to have heard of.

Obviously this is problematic because the NSDictionaryMapNode is not part of a public API and has no useful methods that I need to use for my predicate.

Here's a really simple example:

fetchRequest.predicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
    NSLog(@"%@", NSStringFromClass([evaluatedObject class]);
    return YES;
}];

Here I am expecting evaluatedObject to be an instance of a subclass of NSManagedObject, but instead it is an instance of NSDictionaryMapNode.

I've investigated this further, and it seems that this happens every time I perform a fetch after the first, which works fine. I don't know if it's maybe something to do with deallocation or if I use something twice that I shouldn't.

like image 878
Alyssa Ross Avatar asked Jun 08 '13 18:06

Alyssa Ross


1 Answers

Probably this is the result of uniquing done by core data. See my comment.

Try to access the properties via key-value coding.

like image 198
Amin Negm-Awad Avatar answered Nov 06 '22 03:11

Amin Negm-Awad