Pregunta

I'm trying to check if a string contains my search strings (let's say "cr" for the example).

I have an object A which has multiple objects B, B has an NSArray (named array) of NSDictionary.

The NSDictionary has 2 keys : @"desc" and @"action".

I would like to get all the objects of "A" where at least one of the desc key contains my searchString "cr".

I tried with:

NSPredicate *searchStringPredicate = [NSPredicate predicateWithFormat:@"(SUBQUERY(A.B, $b, ANY $b.array.desc CONTAINS[cd] %@).@count > 0)", @"cr"];

But I keep getting a EXC_BAD_ACCESS (code=2, address=0x0) on :

NSArray *fetchedObjects = [context executeFetchRequest:request error:&error];

Do you have any idea of what's happening ?

¿Fue útil?

Solución

If A has a relationship to B and B has a transformable NSArray (named array) of dictionaries as a property then you can not execute a fetch request to interrogate the contents of the array.

The transformable data is stored as binary in the data store so you can't access it until it has been read into memory and decoded.

If you need to be able to use a fetch request then you will need to convert the array of dictionaries into a relationship to another entity (and once you have done that the syntax of the subquery looks wrong).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top