This repository was archived by the owner on Nov 9, 2017. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Original file line number Diff line number Diff line change 11#import " Entry.h"
22
33@implementation Entry
4+
45- (id )initWithIndex : (NSInteger )index data : (NSNumber *)data {
56 self.index = index;
67 self.data = data;
78 return self;
89}
10+
911@end
Original file line number Diff line number Diff line change @@ -19,19 +19,18 @@ - (NSInteger)tableView:(id)view numberOfRowsInSection:(NSInteger)section {
1919 for (NSInteger i = 0 ; i < num; i++) {
2020 NSString *sizeString = [[(UITableViewCell *)[self tableView: view cellForRowAtIndexPath: [NSIndexPath indexPathForRow: i inSection: section]] detailTextLabel ] text ];
2121 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- }
22+ NSInteger length = [sizeString length ];
23+ if (length > 2 )
24+ switch ([sizeString characterAtIndex: length - 2 ]) {
25+ case ' M' :
26+ size *= 1024 ;
27+ break ;
28+ case ' G' :
29+ size *= 1024 * 1024 ;
30+ break ;
31+ case ' T' :
32+ size *= 1024 * 1024 * 1024 ;
33+ }
3534 [data addObject: [[Entry alloc ] initWithIndex: i data: @(size)]];
3635 }
3736 map = [data sortedArrayUsingComparator: ^NSComparisonResult (Entry *a, Entry *b) {
You can’t perform that action at this time.
0 commit comments