forked from jerrykrinock/CategoriesObjC
/
NSScanner+GeeWhiz.m
36 lines (28 loc) · 952 Bytes
/
NSScanner+GeeWhiz.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#import "NSScanner+GeeWhiz.h"
@implementation NSScanner (GeeWhiz)
- (BOOL)tryScanPastString:(NSString*)target {
BOOL foundTarget = NO ;
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= 1050)
NSUInteger startLoc = [self scanLocation] ;
#else
int unsigned startLoc = [self scanLocation] ;
#endif
[self scanUpToString:target intoString:NULL] ;
if ([self scanString:target intoString:NULL]) {
foundTarget = YES ;
}
else {
[self setScanLocation:startLoc] ;
}
return foundTarget ;
}
- (BOOL)scanUpToAndThenLeapOverString:(NSString*)stopString intoString:(NSString**)stringValue {
[self scanUpToString:stopString
intoString:stringValue] ;
// Note that we ignore the result of the above, which will be NO if the scanner
// was initially at end or parked at beginning of stopString and YES otherwise.
// That's a rather useless and confusing result.
BOOL result = [self scanString:stopString intoString:NULL] ;
return result ;
}
@end