hanumanDev
hanumanDev

Reputation: 6614

NSPredicate syntax question

is the syntax for the line of code below correct?

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"type == %@",selectedAnimalType];

I want the 'selectedAnimalType' string to be used in a search to display the the user selected.

I ran an NSLog statement for the %@ object and it returned what I wanted

NSLog(@"%@",selectedAnimalType);

thanks for any help.

Upvotes: 0

Views: 212

Answers (1)

TechZen
TechZen

Reputation: 64428

Whether it works depends on what class type and selectedBirdType are. If they are both objects like NSStrings or NSNumbers it will work fine. If not you may have problems.

To see exactly what the predicate is just log the predicate object itself. It will print out the exact, populated i.e. with variables substituted, predicate so you can see exactly what is going on.

Upvotes: 1

Related Questions