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.
精彩评论