iOS: Minor cleanup

- Clean up trailing whitespace.
- Get rid of a redundant initialize call.
- Access variables through their property equivalents.
This commit is contained in:
Lioncash 2014-09-20 22:56:41 -04:00
parent f618b6de66
commit 3f8d11e6b7

View File

@ -152,21 +152,17 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
{ {
if ((self = [super initWithStyle:UITableViewStylePlain])) if ((self = [super initWithStyle:UITableViewStylePlain]))
{ {
_path = path ? path : NSHomeDirectory(); self.path = path ? path : NSHomeDirectory();
_chooseAction = action; self.chooseAction = action;
_extensions = extensions ? BOXSTRING(extensions) : 0; self.extensions = extensions ? BOXSTRING(extensions) : 0;
self = [super initWithStyle:UITableViewStylePlain];
self.hidesHeaders = YES; self.hidesHeaders = YES;
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Up" style:UIBarButtonItemStyleBordered target:self self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Up" style:UIBarButtonItemStyleBordered target:self
action:@selector(gotoParent)]; action:@selector(gotoParent)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self
action:@selector(cancelBrowser)]; action:@selector(cancelBrowser)];
// NOTE: The "App" and "Root" buttons aren't really needed for non-jailbreak devices. // NOTE: The "App" and "Root" buttons aren't really needed for non-jailbreak devices.
NSMutableArray* toolbarButtons = [NSMutableArray arrayWithObjects: NSMutableArray* toolbarButtons = [NSMutableArray arrayWithObjects:
[[UIBarButtonItem alloc] initWithTitle:@"Home" style:UIBarButtonItemStyleBordered target:self [[UIBarButtonItem alloc] initWithTitle:@"Home" style:UIBarButtonItemStyleBordered target:self
@ -188,7 +184,6 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
[self.tableView addGestureRecognizer:[[UILongPressGestureRecognizer alloc] initWithTarget:self [self.tableView addGestureRecognizer:[[UILongPressGestureRecognizer alloc] initWithTarget:self
action:@selector(fileAction:)]]; action:@selector(fileAction:)]];
} }
return self; return self;
@ -201,7 +196,7 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
- (void)gotoParent - (void)gotoParent
{ {
[self browseTo:[_path stringByDeletingLastPathComponent]]; [self browseTo:[self.path stringByDeletingLastPathComponent]];
} }
- (void)gotoHomeDir - (void)gotoHomeDir
@ -221,13 +216,13 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
- (void)refresh - (void)refresh
{ {
[self browseTo:_path]; [self browseTo: self.path];
} }
- (void)browseTo:(NSString*)path - (void)browseTo:(NSString*)path
{ {
_path = path; self.path = path;
self.title = _path.lastPathComponent; self.title = self.path.lastPathComponent;
// Need one array per section // Need one array per section
self.sections = [NSMutableArray array]; self.sections = [NSMutableArray array];
@ -236,7 +231,7 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
[self.sections addObject:[NSMutableArray arrayWithObject:i]]; [self.sections addObject:[NSMutableArray arrayWithObject:i]];
// List contents // List contents
struct string_list* contents = dir_list_new(_path.UTF8String, _extensions.UTF8String, true); struct string_list* contents = dir_list_new(self.path.UTF8String, self.extensions.UTF8String, true);
if (contents) if (contents)
{ {
@ -280,7 +275,7 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
- (void)viewWillAppear:(BOOL)animated - (void)viewWillAppear:(BOOL)animated
{ {
[super viewWillAppear:animated]; [super viewWillAppear:animated];
[self browseTo:_path]; [self browseTo: self.path];
} }
- (NSArray*)sectionIndexTitlesForTableView:(UITableView*)tableView - (NSArray*)sectionIndexTitlesForTableView:(UITableView*)tableView
@ -392,10 +387,10 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
NSString* text = [alertView textFieldAtIndex:0].text; NSString* text = [alertView textFieldAtIndex:0].text;
if (text.length) if (text.length)
file_action((enum file_action)alertView.tag, self.selectedItem.path, [_path stringByAppendingPathComponent:text]); file_action((enum file_action)alertView.tag, self.selectedItem.path, [self.path stringByAppendingPathComponent:text]);
} }
[self browseTo:_path]; [self browseTo: self.path];
} }
@end @end
@ -411,10 +406,10 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
if ((self = [super initWithStyle:UITableViewStyleGrouped])) if ((self = [super initWithStyle:UITableViewStyleGrouped]))
{ {
RAFoldersList* __weak weakSelf = self; RAFoldersList* __weak weakSelf = self;
_path = path; self.path = path;
// Parent item // Parent item
NSString* sourceItem = _path.stringByDeletingLastPathComponent; NSString* sourceItem = self.path.stringByDeletingLastPathComponent;
RAMenuItemBasic* parentItem = [RAMenuItemBasic itemWithDescription:BOXSTRING("<Parent>") association:sourceItem.stringByDeletingLastPathComponent RAMenuItemBasic* parentItem = [RAMenuItemBasic itemWithDescription:BOXSTRING("<Parent>") association:sourceItem.stringByDeletingLastPathComponent
action:^(id userdata){ [weakSelf moveInto:userdata]; } detail:NULL]; action:^(id userdata){ [weakSelf moveInto:userdata]; } detail:NULL];
@ -422,7 +417,7 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
// List contents // List contents
struct string_list* contents = dir_list_new([_path stringByDeletingLastPathComponent].UTF8String, 0, true); struct string_list* contents = dir_list_new([self.path stringByDeletingLastPathComponent].UTF8String, 0, true);
NSMutableArray* items = [NSMutableArray arrayWithObject:BOXSTRING("")]; NSMutableArray* items = [NSMutableArray arrayWithObject:BOXSTRING("")];
if (contents) if (contents)
@ -445,7 +440,7 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
dir_list_free(contents); dir_list_free(contents);
} }
[self setTitle:[BOXSTRING("Move ") stringByAppendingString:_path.lastPathComponent]]; [self setTitle:[BOXSTRING("Move ") stringByAppendingString: self.path.lastPathComponent]];
[self.sections addObject:items]; [self.sections addObject:items];
} }