Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 073a0aa

Browse files
author
张国晔
committed
Fix for Korean
there is no space between number and unit
1 parent 3359253 commit 073a0aa

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

Tweak.m

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,22 @@ - (NSInteger)tableView:(id)view numberOfRowsInSection:(NSInteger)section {
1717
num = result - 2;
1818
NSMutableArray *data = [NSMutableArray arrayWithCapacity:num];
1919
for (NSInteger i = 0; i < num; i++) {
20-
NSString *size = [[(UITableViewCell *)[self tableView:view cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:section]] detailTextLabel] text];
21-
NSArray *parts = [size componentsSeparatedByString:@" "];
22-
if ([parts count] == 2)
23-
[data addObject:[[Entry alloc] initWithIndex:i data:@([parts[0] floatValue] * [@{@"KB": @1, @"MB": @1000, @"GB": @1000000, @"TB": @1000000000}[parts[1]] intValue])]];
24-
else
25-
[data addObject:[[Entry alloc] initWithIndex:i data:@0]];
20+
NSString *sizeString = [[(UITableViewCell *)[self tableView:view cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:section]] detailTextLabel] text];
21+
float size = [sizeString floatValue];
22+
switch ([sizeString characterAtIndex:[sizeString length] - 2]) {
23+
case 'K':
24+
size *= 1024;
25+
break;
26+
case 'M':
27+
size *= 1024 * 1024;
28+
break;
29+
case 'G':
30+
size *= 1024 * 1024 * 1024;
31+
break;
32+
case 'T':
33+
size *= 1024 * 1024 * 1024 * 1024;
34+
}
35+
[data addObject:[[Entry alloc] initWithIndex:i data:@(size)]];
2636
}
2737
map = [data sortedArrayUsingComparator:^NSComparisonResult(Entry *a, Entry *b) {
2838
return [b.data compare: a.data];
@@ -40,10 +50,4 @@ - (id)tableView:(id)view cellForRowAtIndexPath:(NSIndexPath *)indexPath {
4050
return %orig(view, indexPath);
4151
}
4252

43-
- (void)viewWillDisappear:(BOOL)animated {
44-
%orig(animated);
45-
map = nil;
46-
count = 0;
47-
}
48-
4953
%end

0 commit comments

Comments
 (0)