Vous pouvez faire « rechercher » des tableaux en utilisant prédicats, comme ceci:
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"
Vous devriez regarder la documentation NSArray et NSPredicate pour plus information. Si vous recherchez des informations spécifiques à l'analyse XML (c'est-à-dire un flux RSS), vous devriez consulter l'article de Matt Gallagher au using libxml2 for XML parsing and XPath queries in Cocoa.
Liens de documentation ajoutés –
should not NSArray * namesStartingWithB = [array filteredArrayUsingPredicate: predicate]; être NSArray * namesStartingWithB = [names filteredArrayUsingPredicate: predicate]; –
@James Merci pour la tête - fixe. –