- Timestamp:
- Aug 14, 2006, 11:39:51 PM (16 years ago)
- Location:
- trunk/macosx
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/StringAdditions.h
r357 r777 40 40 attributes: (NSDictionary *) attributes; 41 41 42 - (NSComparisonResult) compareIP: (NSString *) string; 43 42 44 @end -
trunk/macosx/StringAdditions.m
r424 r777 158 158 } 159 159 160 - (NSComparisonResult) compareIP: (NSString *) string 161 { 162 if ([self isEqualToString: string]) 163 return NSOrderedSame; 164 165 NSEnumerator * selfSections = [[self componentsSeparatedByString: @"."] objectEnumerator], 166 * newSections = [[string componentsSeparatedByString: @"."] objectEnumerator]; 167 168 NSComparisonResult result; 169 NSString * selfString = [selfSections nextObject], * newString = [newSections nextObject]; 170 while (selfString && newString) 171 { 172 if ((result = [selfString compare: newString options: NSNumericSearch]) != NSOrderedSame) 173 return result; 174 175 selfString = [selfSections nextObject]; 176 newString = [newSections nextObject]; 177 } 178 179 if (selfString) 180 return NSOrderedDescending; 181 else if (newString) 182 return NSOrderedAscending; 183 else 184 return NSOrderedSame; 185 } 186 160 187 @end
Note: See TracChangeset
for help on using the changeset viewer.