Permalink
Browse files

Merge pull request #85 from Lax/peek

add peekAtSearchWithXPathQuery method
  • Loading branch information...
2 parents bb1dcfa + b4cf5f0 commit ba66fa9d4a116d758f470cb664c31eb3e14909c9 @topfunky committed Oct 4, 2017
Showing with 11 additions and 0 deletions.
  1. +11 −0 Pod/Classes/TFHppleElement.m
@@ -234,6 +234,17 @@ - (NSArray *) searchWithXPathQuery:(NSString *)xPathOrCSS
return hppleElements;
}
+// Returns first element at xPath
+- (TFHppleElement *) peekAtSearchWithXPathQuery:(NSString *)xPathOrCSS
+{
+ NSArray * elements = [self searchWithXPathQuery:xPathOrCSS];
+ if ([elements count] >= 1) {
+ return [elements objectAtIndex:0];
+ }
+
+ return nil;
+}
+
// Custom keyed subscripting
- (id)objectForKeyedSubscript:(id)key
{

0 comments on commit ba66fa9

Please sign in to comment.