Search code examples
iosobjective-ccore-datamagicalrecord

IOS use CoreData MR_findByAttribute


I'm using MagicalRecord to save my data.

I want to get 2 columns with 2 values

So, I cannot use this method:

[MyData MR_findByAttribute:(NSString *) withValue:(id)]

How to I can 2 columns with 2 values use MagicalRecord

Please help me!


Solution

  • You need to use another fetch method with NSPredicate:

    NSPredicate *filter = [NSPredicate predicateWithFormat:@"atribute1=%@ AND attribute2=%@", value1, value2];
    NSArray *result = [Model MR_findAllWithPredicate: filter];
    

    take a look at this article