过滤其中包含字典的 NSArray - swift 1.2
Filtering NSArray having Dictionary inside it - swift 1.2
(
{
"creation_date" = "23-02-2016 18:29";
filename = "abc.pdf";
},
{
"creation_date" = "23-02-2016 18:28";
filename = "32.pdf";
},
{
"creation_date" = "23-02-2016 18:28";
filename = "78.pdf";
},
{
"creation_date" = "23-02-2016 17:28";
filename = "65.pdf";
},
{
"creation_date" = "23-02-2016 16:48";
filename = "6.pdf";
}
)
我有这样的 NSArray。我想要 NSMutableDictionary 的 Filtered NSArray,它有文件名 = SearchString。意味着我正在使用 searchBarController,所以当我搜索某些内容时,它应该过滤在字典中具有该搜索文件名的数组。
我怎样才能做到这一点?有什么建议吗?
谢谢
var fileterArray: NSArray = yourArray.filteredArrayUsingPredicate(NSPredicate(format: "self.%@ contains[c] %@", "filename", "SearchString"))
print(fileterArray)
(
{
"creation_date" = "23-02-2016 18:29";
filename = "abc.pdf";
},
{
"creation_date" = "23-02-2016 18:28";
filename = "32.pdf";
},
{
"creation_date" = "23-02-2016 18:28";
filename = "78.pdf";
},
{
"creation_date" = "23-02-2016 17:28";
filename = "65.pdf";
},
{
"creation_date" = "23-02-2016 16:48";
filename = "6.pdf";
}
)
我有这样的 NSArray。我想要 NSMutableDictionary 的 Filtered NSArray,它有文件名 = SearchString。意味着我正在使用 searchBarController,所以当我搜索某些内容时,它应该过滤在字典中具有该搜索文件名的数组。 我怎样才能做到这一点?有什么建议吗?
谢谢
var fileterArray: NSArray = yourArray.filteredArrayUsingPredicate(NSPredicate(format: "self.%@ contains[c] %@", "filename", "SearchString"))
print(fileterArray)