views:

23

answers:

1

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.

+1  A: 

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.

TechZen