开发者

NSPredicate syntax question

开发者 https://www.devze.com 2023-01-13 23:18 出处:网络
is the 开发者_如何学Gosyntax for the line of code below correct? NSPredicate *predicate = [NSPredicate predicateWithFormat:@\"type == %@\",selectedAnimalType];

is the 开发者_如何学Gosyntax 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消