Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cocoa 如何在NSPredicate中获取特定字符串_Cocoa_Macos_Nspredicate - Fatal编程技术网

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文档:。