Cocoa 如何在NSPredicate中获取特定字符串
如何在Cocoa 如何在NSPredicate中获取特定字符串,cocoa,macos,nspredicate,Cocoa,Macos,Nspredicate,如何在NSPredicate中获取字符串“NSMetadataItemFSNameKey==*”predicateWithFormat不工作并崩溃 Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "NSMetadataItemFSNameKey = *"' 如果您有字符串@“NSMetadataItemFSName
NSPredicate
中获取字符串“NSMetadataItemFSNameKey==*”
predicateWithFormat
不工作并崩溃
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse the format string "NSMetadataItemFSNameKey = *"'
如果您有字符串
@“NSMetadataItemFSNameKey==*”
,并且希望将其转换为谓词,则不能。它的格式不正确,因此您将获得异常
它需要是:
@“NSMetadataItemFSNameKey=='*'”
。星号周围的单引号非常重要。你到底想做什么?你能在创建谓词的地方发布代码吗?你想和什么比赛?您希望此NSMetadataItemFSKey可以是任何内容吗?如果是这样的话,为什么还要有谓词呢?这个谓词来自Apple文档:。