views:

15

answers:

0

Hello everyone,

I have 2 tables, 1 table is called table car and 2nd is called history.

A car can have many histories so basically a history will have a foreign key carid which represents the car id.

I am trying to extract all the history that is associated with the car but unfortunately, it keeps returning me every single history.

I think am doing something wrong with the nspredicate.

Below is the sample code:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(carid == %@)", currentCar.id ];

[request setPredicate:predicate];

I am trying to retrieve the history from the history table whose carid is the same as the currentcar.id

I printed the currentcar.id to check if it is fine and when it is 0, it returns me everything and when it is 1 it also returns me everything.

Any ideas?