Monotone-Parent: b54cbfbf869e5f43716f3c46ec9c9461fca6684f

Monotone-Revision: 13b85b286011f096c4141829b528972047581e57

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-05-30T20:03:19
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2007-05-30 20:03:19 +00:00
parent 5a1a0f7d5e
commit b1f65b01e4
3 changed files with 38 additions and 0 deletions

View File

@@ -1,5 +1,11 @@
2007-05-30 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/SOGo/NSArray+Utilities.m ([NSMutableArray
-addRange:newRange]): new method that store a string
representation of the NSRange passed as parameter.
([NSMutableArray -hasRangeIntersection:testRange]): tests whether
any range contained in self intersect with the one passed as parameter.
* SoObjects/SOGo/NSString+Utilities.m ([-stringByDetectingURLs]):
store ranges in an array to prevent them from intersecting with
each other during the passes.

View File

@@ -45,6 +45,9 @@
- (void) addObjectUniquely: (id) object;
- (void) addRange: (NSRange) newRange;
- (BOOL) hasRangeIntersection: (NSRange) testRange;
@end
#endif /* NSARRAY_UTILITIES_H */

View File

@@ -91,5 +91,34 @@
[self addObject: object];
}
- (void) addRange: (NSRange) newRange
{
[self addObject: NSStringFromRange (newRange)];
}
- (BOOL) hasRangeIntersection: (NSRange) testRange
{
NSEnumerator *ranges;
NSString *currentRangeString;
NSRange currentRange;
BOOL response;
response = NO;
ranges = [self objectEnumerator];
currentRangeString = [ranges nextObject];
while (!response && currentRangeString)
{
currentRange = NSRangeFromString (currentRangeString);
if (NSLocationInRange (testRange.location, currentRange)
|| NSLocationInRange (NSMaxRange (testRange), currentRange))
response = YES;
else
currentRangeString = [ranges nextObject];
}
return response;
}
@end