2011-06-08 66 views
3

如何獲取字符串"NSMetadataItemFSNameKey == *"NSPredicatepredicateWithFormat不起作用並崩潰。如何獲得NSPredicate中的特定字符串

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

你究竟想要做什麼?你能在你創建謂詞的地方發佈代碼嗎?你想匹配什麼?你希望這個NSMetadataItemFSKey能夠成爲什麼?如果是這樣的話,爲什麼要有謂詞呢? – Enchilada 2011-06-09 00:33:39

+0

此謂詞來自Apple文檔:[click](https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/iCloud/iCloud.html#//apple_ref/doc/uid/TP40010672 -CH12-SW50)。 – lawicko 2013-09-20 16:12:04

回答

2

如果你有字符串@"NSMetadataItemFSNameKey == *"並且想把它變成一個謂詞,你不能。這是畸形的,因此你得到的例外。

它需要是:@"NSMetadataItemFSNameKey == '*'"。圍繞星號的單引號非常重要。

相關問題