How to search nsmutablearray in objective c-iPhone app

前端 未结 1 1801
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-15 13:32

I am reading a RSS feed into nsmutablearray. i want to search the xml feed. for that i want to search nsmutablearray. i am very new to iphone apps. can some one helpme with

1条回答
  •  时光说笑
    2020-12-15 14:12

    You can do "searching" of arrays using predicates, like so:

    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"
    

    You should look at the NSArray and NSPredicate documentation for more information. If you're after information specific to parsing XML (i.e. an RSS feed), you should check out Matt Gallagher's article on using libxml2 for XML parsing and XPath queries in Cocoa.

    0 讨论(0)
提交回复
热议问题