<string key="IBDocument.HIToolboxVersion">352.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="1039"/>
+ <integer value="1042"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<int key="NSResizingMask">2</int>
<bool key="NSIsResizeable">YES</bool>
<reference key="NSTableView" ref="221969066"/>
- <object class="NSSortDescriptor" key="NSSortDescriptorPrototype" id="631031026">
+ <object class="NSSortDescriptor" key="NSSortDescriptorPrototype">
<string key="NSKey">IP</string>
<bool key="NSAscending">YES</bool>
- <string key="NSSelector">compareIP:</string>
+ <string key="NSSelector">compareNumeric:</string>
</object>
</object>
<object class="NSTableColumn" id="510868589">
<string key="NSAutosaveName">InspectorTable</string>
<object class="NSArray" key="NSSortDescriptors">
<bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="631031026"/>
<reference ref="116573225"/>
</object>
<int key="NSColumnAutoresizingStyle">1</int>
if (useSecond)
{
NSSortDescriptor * secondDescriptor = [[NSSortDescriptor alloc] initWithKey: @"IP" ascending: asc
- selector: @selector(compareIP:)];
+ selector: @selector(compareFinder:)];
[descriptors addObject: secondDescriptor];
[secondDescriptor release];
}
+ (NSString *) timeString: (NSUInteger) seconds showSeconds: (BOOL) showSeconds maxFields: (NSUInteger) max;
- (NSComparisonResult) compareFinder: (NSString *) string; //how the Finder compares strings
-- (NSComparisonResult) compareIP: (NSString *) string;
+- (NSComparisonResult) compareNumeric: (NSString *) string; //simple compare method for strings with numbers (works for IP addresses)
@end
- (NSComparisonResult) compareFinder: (NSString *) string
{
- int comparisonOptions = ![NSApp isOnLeopardOrBetter] ? (NSCaseInsensitiveSearch | NSNumericSearch)
- : (NSCaseInsensitiveSearch | NSNumericSearch| NSWidthInsensitiveSearch | NSForcedOrderingSearch);
+ int comparisonOptions = [NSApp isOnLeopardOrBetter] ? (NSCaseInsensitiveSearch | NSNumericSearch
+ | NSWidthInsensitiveSearch | NSForcedOrderingSearch)
+ : (NSCaseInsensitiveSearch | NSNumericSearch);
return [self compare: string options: comparisonOptions range: NSMakeRange(0, [self length]) locale: [NSLocale currentLocale]];
}
-- (NSComparisonResult) compareIP: (NSString *) string
-{
- NSArray * selfSections = [self componentsSeparatedByString: @"."],
- * newSections = [string componentsSeparatedByString: @"."];
-
- if ([selfSections count] != [newSections count])
- return [selfSections count] > [newSections count] ? NSOrderedDescending : NSOrderedAscending;
-
- NSEnumerator * selfSectionsEnum = [selfSections objectEnumerator], * newSectionsEnum = [newSections objectEnumerator];
- NSString * selfString, * newString;
+- (NSComparisonResult) compareNumeric: (NSString *) string
+{
int comparisonOptions = [NSApp isOnLeopardOrBetter] ? (NSNumericSearch | NSForcedOrderingSearch) : NSNumericSearch;
- NSComparisonResult result;
- while ((selfString = [selfSectionsEnum nextObject]) && (newString = [newSectionsEnum nextObject]))
- if ((result = [selfString compare: newString options: comparisonOptions
- range: NSMakeRange(0, [selfString length]) locale: [NSLocale currentLocale]]) != NSOrderedSame)
- return result;
- return NSOrderedSame;
+ return [self compare: string options: comparisonOptions range: NSMakeRange(0, [self length]) locale: [NSLocale currentLocale]];
}
@end