core data - Filter out child entities from parents and display the results in iOS -


My problem is very common and lame (for me), although I can not find the solution

I have a basic setup of basic data, a source object that works as a parent, and has many connections with its item .

The item object is now just one itemName property is simplicity.

I display these values ​​in a table view, because the source objects are sections and their child bodies are the table view tables.

All the great when I want to bring buses, because I only fetch the source object and display all their items.

The problem comes when I want to filter these values ​​from text in the search bar. I do not know what type of use I should use to get the desired value, I want to display items that include text entered in the search bar in the ItemName property.

I tried the code below, but it does not help, it displays the right source object (one or more items have their letters), but it will show all their items children's objects, Whom I do not want :)

  NSPredicate * predicate = [NSPredicate predicateWithFormat: @ "item. @ Count! = 0 more item. [C]% @ in searchname, searchTerm]; NSSortDescriptor * dateSortDescriptor = [NSSortDescriptor sortDescriptorWithKey: @ "Modification Date" ascending: no]; Return [auto fetchCoreDataForEntityName: @ "Source" with advanced: Bill with Sartadcopyter: DateScopySpeaker];   

Any ideas? I think it is very easy to solve, but I do not know how. Thanks in advance. :)

Believing that relationships are multiple-to-one, I recommend that you get The result will not bring the controller to source , but with the item unit sectionNameKeyPath and the attribute name for its source Set up, e.g. @ "source.title" . Now ingenious is straightforward:

  [Nupdicket project with format: @ "item name [c]% @", searchstress];   

(To follow the convention, I recommend changing your attribute name to name . item.itemName seems unnecessary Is.)

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -