summaryrefslogtreecommitdiff
path: root/platform/ios/Classes/MuLibraryController.m
diff options
context:
space:
mode:
authorJoseph Heenan <joseph@emobix.co.uk>2016-06-07 16:46:14 +0100
committerJoseph Heenan <joseph@emobix.co.uk>2016-06-09 10:57:47 +0100
commita3ab5aa8e840ba10f9c259a3e3f07d76f4562428 (patch)
treefa76a4aa5301d5916efe719ec7fcaec14bcbe993 /platform/ios/Classes/MuLibraryController.m
parent641935ed19f95dfb7eab1309905e960389628289 (diff)
downloadmupdf-a3ab5aa8e840ba10f9c259a3e3f07d76f4562428.tar.xz
iOS: Run Xcode's "Convert to Modern ObjC" for "ObjC literals"
Uses the more modern/concise syntax that arrived in Xcode 4.4
Diffstat (limited to 'platform/ios/Classes/MuLibraryController.m')
-rw-r--r--platform/ios/Classes/MuLibraryController.m56
1 files changed, 28 insertions, 28 deletions
diff --git a/platform/ios/Classes/MuLibraryController.m b/platform/ios/Classes/MuLibraryController.m
index 10541475..31a78914 100644
--- a/platform/ios/Classes/MuLibraryController.m
+++ b/platform/ios/Classes/MuLibraryController.m
@@ -26,7 +26,7 @@ static void showAlert(NSString *msg, NSString *filename)
- (void) viewWillAppear: (BOOL)animated
{
[super viewWillAppear:animated];
- [self setTitle: @"PDF, XPS, CBZ and EPUB Documents"];
+ self.title = @"PDF, XPS, CBZ and EPUB Documents";
[self reload];
timer = [NSTimer timerWithTimeInterval: 3
target: self selector: @selector(reload) userInfo: nil
@@ -63,7 +63,7 @@ static void showAlert(NSString *msg, NSString *filename)
files = outfiles;
- [[self tableView] reloadData];
+ [self.tableView reloadData];
}
- (void) dealloc
@@ -85,21 +85,21 @@ static void showAlert(NSString *msg, NSString *filename)
- (NSInteger) tableView: (UITableView*)tableView numberOfRowsInSection: (NSInteger)section
{
- return [files count];
+ return files.count;
}
- (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
- if (buttonIndex == [actionSheet destructiveButtonIndex])
+ if (buttonIndex == actionSheet.destructiveButtonIndex)
{
char filename[PATH_MAX];
- NSInteger row = [actionSheet tag];
+ NSInteger row = actionSheet.tag;
dispatch_sync(queue, ^{});
strcpy(filename, [NSHomeDirectory() UTF8String]);
strcat(filename, "/Documents/");
- strcat(filename, [[files objectAtIndex: row] UTF8String]);
+ strcat(filename, [files[row] UTF8String]);
unlink(filename);
@@ -109,16 +109,16 @@ static void showAlert(NSString *msg, NSString *filename)
- (void) onTapDelete: (UIControl*)sender
{
- NSInteger row = [sender tag];
- NSString *title = [NSString stringWithFormat: @"Delete %@?", [files objectAtIndex:row]];
+ NSInteger row = sender.tag;
+ NSString *title = [NSString stringWithFormat: @"Delete %@?", files[row]];
UIActionSheet *sheet = [[UIActionSheet alloc]
initWithTitle: title
delegate: self
cancelButtonTitle: @"Cancel"
destructiveButtonTitle: @"Delete"
otherButtonTitles: nil];
- [sheet setTag: row];
- [sheet showInView: [self tableView]];
+ sheet.tag = row;
+ [sheet showInView: self.tableView];
[sheet release];
}
@@ -128,24 +128,24 @@ static void showAlert(NSString *msg, NSString *filename)
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: cellid];
if (!cell)
cell = [[[UITableViewCell alloc] initWithStyle: UITableViewCellStyleDefault reuseIdentifier: cellid] autorelease];
- NSInteger row = [indexPath row];
- [[cell textLabel] setText: [files objectAtIndex: row]];
- [[cell textLabel] setFont: [UIFont systemFontOfSize: 20]];
+ NSInteger row = indexPath.row;
+ cell.textLabel.text = files[row];
+ cell.textLabel.font = [UIFont systemFontOfSize: 20];
UIButton *deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
[deleteButton setImage: [UIImage imageNamed: @"x_alt_blue.png"] forState: UIControlStateNormal];
- [deleteButton setFrame: CGRectMake(0, 0, 35, 35)];
+ deleteButton.frame = CGRectMake(0, 0, 35, 35);
[deleteButton addTarget: self action: @selector(onTapDelete:) forControlEvents: UIControlEventTouchUpInside];
- [deleteButton setTag: row];
- [cell setAccessoryView: deleteButton];
+ deleteButton.tag = row;
+ cell.accessoryView = deleteButton;
return cell;
}
- (void) tableView: (UITableView*)tableView didSelectRowAtIndexPath: (NSIndexPath*)indexPath
{
- NSInteger row = [indexPath row];
- [self openDocument: [files objectAtIndex: row]];
+ NSInteger row = indexPath.row;
+ [self openDocument: files[row]];
}
static NSString *alteredfilename(NSString *name, int i)
@@ -153,8 +153,8 @@ static NSString *alteredfilename(NSString *name, int i)
if (i == 0)
return name;
- NSString *nam = [name stringByDeletingPathExtension];
- NSString *e = [name pathExtension];
+ NSString *nam = name.stringByDeletingPathExtension;
+ NSString *e = name.pathExtension;
return [[[NSString alloc] initWithFormat:@"%@(%d).%@", nam, i, e] autorelease];
}
@@ -168,11 +168,11 @@ static NSString *moveOutOfInbox(NSString *docpath)
for (int i = 0; YES; i++)
{
NSString *newname = alteredfilename(base, i);
- NSString *newfullpath = [NSString pathWithComponents:[NSArray arrayWithObjects:NSHomeDirectory(), @"Documents", newname, nil]];
+ NSString *newfullpath = [NSString pathWithComponents:@[NSHomeDirectory(), @"Documents", newname]];
if (![fileMan fileExistsAtPath:newfullpath])
{
- NSString *fullpath = [NSString pathWithComponents:[NSArray arrayWithObjects:NSHomeDirectory(), @"Documents", docpath, nil]];
+ NSString *fullpath = [NSString pathWithComponents:@[NSHomeDirectory(), @"Documents", docpath]];
[fileMan copyItemAtPath:fullpath toPath:newfullpath error:nil];
[fileMan removeItemAtPath:fullpath error:nil];
return newname;
@@ -186,7 +186,7 @@ static NSString *moveOutOfInbox(NSString *docpath)
- (void) openDocument: (NSString*)nsfilename
{
nsfilename = moveOutOfInbox(nsfilename);
- _filePath = [[[NSArray arrayWithObjects:NSHomeDirectory(), @"Documents", nsfilename, nil]
+ _filePath = [[@[NSHomeDirectory(), @"Documents", nsfilename]
componentsJoinedByString:@"/"] retain];
if (_filePath == NULL) {
showAlert(@"Out of memory in openDocument", nsfilename);
@@ -213,18 +213,18 @@ static NSString *moveOutOfInbox(NSString *docpath)
{
UIAlertView *passwordAlertView = [[UIAlertView alloc]
initWithTitle: @"Password Protected"
- message: [NSString stringWithFormat: prompt, [_filename lastPathComponent]]
+ message: [NSString stringWithFormat: prompt, _filename.lastPathComponent]
delegate: self
cancelButtonTitle: @"Cancel"
otherButtonTitles: @"Done", nil];
- [passwordAlertView setAlertViewStyle: UIAlertViewStyleSecureTextInput];
+ passwordAlertView.alertViewStyle = UIAlertViewStyleSecureTextInput;
[passwordAlertView show];
[passwordAlertView release];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
- const char *password = [[[alertView textFieldAtIndex: 0] text] UTF8String];
+ const char *password = [alertView textFieldAtIndex: 0].text.UTF8String;
[alertView dismissWithClickedButtonIndex: buttonIndex animated: TRUE];
if (buttonIndex == 1) {
if (fz_authenticate_password(ctx, doc->doc, password))
@@ -240,8 +240,8 @@ static NSString *moveOutOfInbox(NSString *docpath)
{
MuDocumentController *document = [[MuDocumentController alloc] initWithFilename: _filename path:_filePath document: doc];
if (document) {
- [self setTitle: @"Library"];
- [[self navigationController] pushViewController: document animated: YES];
+ self.title = @"Library";
+ [self.navigationController pushViewController: document animated: YES];
[document release];
}
[_filename release];