Reputation: 3
CoreDataModel:(I put JSONFORMAT HERE.)
Questions [{qid:1,comments:[{cid:1,user:{'uid':3}},{cid:2,user:{'uid':4}}]},
{qid:2,comments:[{cid:1,user:{'uid':4}},{cid:2,user:{'uid':5}}]}]
Question has relation with comments one2many, comment has one2one relation with user.
How do I search the question which had been commentd by the user (uid=1), using NSPredicate?
below is my model pic
Upvotes: 0
Views: 1328
Reputation: 6011
Request entity should be Question
[NSPredicate predicateWithFormat:SUBQUERY(comments,$comment,$comment.user.usr_id == %@).@count != 0",userId]
Upvotes: 2