开发者

How to get specific string in NSPredicate

开发者 https://www.devze.com 2023-03-11 02:58 出处:网络
How to get the string 开发者_StackOverflow中文版\"NSMetadataItemFSNameKey == *\" in a NSPredicate? predicateWithFormat doesn\'t work and crashes.

How to get the string 开发者_StackOverflow中文版"NSMetadataItemFSNameKey == *" in a NSPredicate? predicateWithFormat doesn't work and crashes.

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "NSMetadataItemFSNameKey = *"'


If you have the string @"NSMetadataItemFSNameKey == *" and want to turn it into a predicate, you can't. It's malformed, hence the exception you're getting.

It would need to be: @"NSMetadataItemFSNameKey == '*'". Those single quotes around the asterisk are incredibly important.

0

精彩评论

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

关注公众号