Search code examples
ioscore-datapredicates

Predicates in coredata in objectivec


I have two tables in coredata Details and person. Person has two fields Id and Code:

Id Code IAS RT IAS TP IAS IP

Now,detailshas two fields,code and Name

Code Name RT Rataz TP Tranzps IP Irrz

Now I want to use predicates so that i can first fetch the id from person,then after getting the field against the id.I can use the same id as predicate to get Name from person table.How this can be achieved.Any help or suggestion would be appreciated.Thanks in advance.


Solution

  • OK, how you should do this is using a relationship.

    Add a relationship to Person called "details" and add a relationship to Detail called "people" (or "person" if it's singular).

    Now you can get the person by the id and then use person.details to get the details associated with that person.

    Core Data is not a database. Think of it more as a data model. Create the data model and object relationships that you need and use them.

    You would be better off checking out a core data tutorial. It will help you in understanding how to use core data.