I can't understand how to use predicate, I have a very long code to filter objects from array by property "type" and suddenly I saw method "filteredArrayUsingPredicate" that can make my life better. I try write predicates but I always get errors; can someone show me how to write it right?
I have method - (void) filterData: (NSString *)filteredWord
:
I also have array with objects (Event): NSArray *eventsArray. I want use a filteredArrayUsingPredicate to get new array with objects (Event) where their property (type) is equal filterWord. Note that Event is Core Data Managed subclass.
Is it even possible to do this with predicate?
One of my attempts:
NSString *propertyName = @"type";
NSArray *eventsArray = [[[[self currentPerson] events] objectEnumerator]allObjects];
NSPredicate *predicte = [NSPredicate predicateWithFormat:@"%k like '%@'",propertyName,filteredWord];
[eventsArray filteredArrayUsingPredicate:predicte];