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]))
{
_path = path ? path : NSHomeDirectory();
_chooseAction = action;
_extensions = extensions ? BOXSTRING(extensions) : 0;
self = [super initWithStyle:UITableViewStylePlain];
self.path = path ? path : NSHomeDirectory();
self.chooseAction = action;
self.extensions = extensions ? BOXSTRING(extensions) : 0;
self.hidesHeaders = YES;
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Up" style:UIBarButtonItemStyleBordered target:self
action:@selector(gotoParent)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self
action:@selector(cancelBrowser)];
// NOTE: The "App" and "Root" buttons aren't really needed for non-jailbreak devices.
NSMutableArray* toolbarButtons = [NSMutableArray arrayWithObjects:
[[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
action:@selector(fileAction:)]];
}
return self;
@ -201,7 +196,7 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
- (void)gotoParent
{
[self browseTo:[_path stringByDeletingLastPathComponent]];
[self browseTo:[self.path stringByDeletingLastPathComponent]];
}
- (void)gotoHomeDir
@ -221,13 +216,13 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
- (void)refresh
{
[self browseTo:_path];
[self browseTo: self.path];
}
- (void)browseTo:(NSString*)path
{
_path = path;
self.title = _path.lastPathComponent;
self.path = path;
self.title = self.path.lastPathComponent;
// Need one array per section
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]];
// 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)
{
@ -280,7 +275,7 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self browseTo:_path];
[self browseTo: self.path];
}
- (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;
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
@ -411,10 +406,10 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
if ((self = [super initWithStyle:UITableViewStyleGrouped]))
{
RAFoldersList* __weak weakSelf = self;
_path = path;
self.path = path;
// Parent item
NSString* sourceItem = _path.stringByDeletingLastPathComponent;
NSString* sourceItem = self.path.stringByDeletingLastPathComponent;
RAMenuItemBasic* parentItem = [RAMenuItemBasic itemWithDescription:BOXSTRING("<Parent>") association:sourceItem.stringByDeletingLastPathComponent
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
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("")];
if (contents)
@ -445,7 +440,7 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
dir_list_free(contents);
}
[self setTitle:[BOXSTRING("Move ") stringByAppendingString:_path.lastPathComponent]];
[self setTitle:[BOXSTRING("Move ") stringByAppendingString: self.path.lastPathComponent]];
[self.sections addObject:items];
}