如何在客观的c-iPhone应用程序中搜索nsmutablearray

nbo*_*jja 5 iphone objective-c

我正在读取nsmutablearray的RSS提要.我想搜索xml提要.因为我想搜索nsmutablearray.我是iphone应用程序的新手.有人可以帮我弄这个吗..

谢谢,

Nat*_*ies 18

您可以使用谓词"搜索"数组,如下所示:

NSMutableArray* names = [NSMutableArray arrayWithObjects:@"Andy", @"Bart", @"Bob", nil]; 
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"SELF beginswith[c] 'b'"];
NSArray* namesStartingWithB = [names filteredArrayUsingPredicate: predicate];
// namesStartingWithB now contains @"Bart" & @"Bob"
Run Code Online (Sandbox Code Playgroud)

您应该查看NSArrayNSPredicate文档以获取更多信息.如果您正在处理特定于解析XML的信息(即RSS提要),那么您应该查看Matt Gallagher关于在Cocoa中使用libxml2进行XML解析和XPath查询的文章.