Changeset 6261
- Timestamp:
- Jun 27, 2008, 5:40:22 AM (14 years ago)
- Location:
- trunk/macosx
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/English.lproj/InfoWindow.xib
r6260 r6261 9 9 <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> 10 10 <bool key="EncodedWithXMLCoder">YES</bool> 11 <integer value="10 39"/>11 <integer value="1042"/> 12 12 </object> 13 13 <object class="NSArray" key="IBDocument.PluginDependencies"> … … 2288 2288 <bool key="NSIsResizeable">YES</bool> 2289 2289 <reference key="NSTableView" ref="221969066"/> 2290 <object class="NSSortDescriptor" key="NSSortDescriptorPrototype" id="631031026">2290 <object class="NSSortDescriptor" key="NSSortDescriptorPrototype"> 2291 2291 <string key="NSKey">IP</string> 2292 2292 <bool key="NSAscending">YES</bool> 2293 <string key="NSSelector">compare IP:</string>2293 <string key="NSSelector">compareNumeric:</string> 2294 2294 </object> 2295 2295 </object> … … 3852 3852 <object class="NSArray" key="NSSortDescriptors"> 3853 3853 <bool key="EncodedWithXMLCoder">YES</bool> 3854 <reference ref="631031026"/>3855 3854 <reference ref="116573225"/> 3856 3855 </object> -
trunk/macosx/InfoWindowController.m
r6252 r6261 1593 1593 { 1594 1594 NSSortDescriptor * secondDescriptor = [[NSSortDescriptor alloc] initWithKey: @"IP" ascending: asc 1595 selector: @selector(compare IP:)];1595 selector: @selector(compareFinder:)]; 1596 1596 [descriptors addObject: secondDescriptor]; 1597 1597 [secondDescriptor release]; -
trunk/macosx/NSStringAdditions.h
r6260 r6261 40 40 41 41 - (NSComparisonResult) compareFinder: (NSString *) string; //how the Finder compares strings 42 - (NSComparisonResult) compare IP: (NSString *) string;42 - (NSComparisonResult) compareNumeric: (NSString *) string; //simple compare method for strings with numbers (works for IP addresses) 43 43 44 44 @end -
trunk/macosx/NSStringAdditions.m
r6260 r6261 148 148 - (NSComparisonResult) compareFinder: (NSString *) string 149 149 { 150 int comparisonOptions = ![NSApp isOnLeopardOrBetter] ? (NSCaseInsensitiveSearch | NSNumericSearch) 151 : (NSCaseInsensitiveSearch | NSNumericSearch| NSWidthInsensitiveSearch | NSForcedOrderingSearch); 150 int comparisonOptions = [NSApp isOnLeopardOrBetter] ? (NSCaseInsensitiveSearch | NSNumericSearch 151 | NSWidthInsensitiveSearch | NSForcedOrderingSearch) 152 : (NSCaseInsensitiveSearch | NSNumericSearch); 152 153 153 154 return [self compare: string options: comparisonOptions range: NSMakeRange(0, [self length]) locale: [NSLocale currentLocale]]; 154 155 } 155 156 156 - (NSComparisonResult) compareIP: (NSString *) string 157 { 158 NSArray * selfSections = [self componentsSeparatedByString: @"."], 159 * newSections = [string componentsSeparatedByString: @"."]; 157 - (NSComparisonResult) compareNumeric: (NSString *) string 158 { 159 int comparisonOptions = [NSApp isOnLeopardOrBetter] ? (NSNumericSearch | NSForcedOrderingSearch) : NSNumericSearch; 160 160 161 if ([selfSections count] != [newSections count]) 162 return [selfSections count] > [newSections count] ? NSOrderedDescending : NSOrderedAscending; 163 164 NSEnumerator * selfSectionsEnum = [selfSections objectEnumerator], * newSectionsEnum = [newSections objectEnumerator]; 165 NSString * selfString, * newString; 166 int comparisonOptions = [NSApp isOnLeopardOrBetter] ? (NSNumericSearch | NSForcedOrderingSearch) : NSNumericSearch; 167 NSComparisonResult result; 168 while ((selfString = [selfSectionsEnum nextObject]) && (newString = [newSectionsEnum nextObject])) 169 if ((result = [selfString compare: newString options: comparisonOptions 170 range: NSMakeRange(0, [selfString length]) locale: [NSLocale currentLocale]]) != NSOrderedSame) 171 return result; 172 173 return NSOrderedSame; 161 return [self compare: string options: comparisonOptions range: NSMakeRange(0, [self length]) locale: [NSLocale currentLocale]]; 174 162 } 175 163
Note: See TracChangeset
for help on using the changeset viewer.