开发者

How to get specific string in NSPredicate

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜