diff options
author | Joseph Heenan <joseph@emobix.co.uk> | 2016-06-07 16:46:14 +0100 |
---|---|---|
committer | Joseph Heenan <joseph@emobix.co.uk> | 2016-06-09 10:57:47 +0100 |
commit | a3ab5aa8e840ba10f9c259a3e3f07d76f4562428 (patch) | |
tree | fa76a4aa5301d5916efe719ec7fcaec14bcbe993 /platform/ios | |
parent | 641935ed19f95dfb7eab1309905e960389628289 (diff) | |
download | mupdf-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')
-rw-r--r-- | platform/ios/Classes/MuAppDelegate.m | 20 | ||||
-rw-r--r-- | platform/ios/Classes/MuChoiceFieldController.m | 8 | ||||
-rw-r--r-- | platform/ios/Classes/MuDocumentController.m | 255 | ||||
-rw-r--r-- | platform/ios/Classes/MuHitView.m | 2 | ||||
-rw-r--r-- | platform/ios/Classes/MuInkView.m | 6 | ||||
-rw-r--r-- | platform/ios/Classes/MuLibraryController.m | 56 | ||||
-rw-r--r-- | platform/ios/Classes/MuOutlineController.m | 24 | ||||
-rw-r--r-- | platform/ios/Classes/MuPageViewNormal.m | 80 | ||||
-rw-r--r-- | platform/ios/Classes/MuPageViewReflow.m | 2 | ||||
-rw-r--r-- | platform/ios/Classes/MuWord.m | 2 | ||||
-rw-r--r-- | platform/ios/main.m | 2 |
11 files changed, 228 insertions, 229 deletions
diff --git a/platform/ios/Classes/MuAppDelegate.m b/platform/ios/Classes/MuAppDelegate.m index 5751cb1e..12f9978f 100644 --- a/platform/ios/Classes/MuAppDelegate.m +++ b/platform/ios/Classes/MuAppDelegate.m @@ -33,25 +33,25 @@ [Fabric with:@[[Crashlytics class]]]; #endif - screenScale = [[UIScreen mainScreen] scale]; + screenScale = [UIScreen mainScreen].scale; library = [[MuLibraryController alloc] initWithStyle: UITableViewStylePlain]; navigator = [[UINavigationController alloc] initWithRootViewController: library]; - [[navigator navigationBar] setTranslucent: YES]; - [[navigator toolbar] setTranslucent: YES]; - [navigator setDelegate: self]; + [navigator.navigationBar setTranslucent: YES]; + [navigator.toolbar setTranslucent: YES]; + navigator.delegate = self; - window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; - [window setBackgroundColor: [UIColor grayColor]]; - [window setRootViewController: navigator]; + window = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen].bounds]; + window.backgroundColor = [UIColor grayColor]; + window.rootViewController = navigator; [window makeKeyAndVisible]; filename = [[NSUserDefaults standardUserDefaults] objectForKey: @"OpenDocumentKey"]; if (filename) [library openDocument: filename]; - filename = [launchOptions objectForKey: UIApplicationLaunchOptionsURLKey]; + filename = launchOptions[UIApplicationLaunchOptionsURLKey]; NSLog(@"urlkey = %@\n", filename); return YES; @@ -60,8 +60,8 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { NSLog(@"openURL: %@\n", url); - if ([url isFileURL]) { - NSString *path = [url path]; + if (url.fileURL) { + NSString *path = url.path; NSString *dir = [NSString stringWithFormat: @"%@/Documents/", NSHomeDirectory()]; path = [path stringByReplacingOccurrencesOfString:@"/private" withString:@""]; path = [path stringByReplacingOccurrencesOfString:dir withString:@""]; diff --git a/platform/ios/Classes/MuChoiceFieldController.m b/platform/ios/Classes/MuChoiceFieldController.m index e30ff000..3a3aee94 100644 --- a/platform/ios/Classes/MuChoiceFieldController.m +++ b/platform/ios/Classes/MuChoiceFieldController.m @@ -48,12 +48,12 @@ - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { - return [choices count]; + return choices.count; } - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { - return [choices objectAtIndex:row]; + return choices[row]; } - (void) pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component @@ -63,8 +63,8 @@ - (IBAction)onOkay:(id)sender { - if (selected >= 0 && selected < [choices count]) - okayBlock([NSArray arrayWithObject:[choices objectAtIndex:selected]]); + if (selected >= 0 && selected < choices.count) + okayBlock(@[choices[selected]]); [self dismissViewControllerAnimated:YES completion:nil]; } diff --git a/platform/ios/Classes/MuDocumentController.m b/platform/ios/Classes/MuDocumentController.m index 2471249a..a06e5912 100644 --- a/platform/ios/Classes/MuDocumentController.m +++ b/platform/ios/Classes/MuDocumentController.m @@ -33,9 +33,9 @@ static void flattenOutline(NSMutableArray *titles, NSMutableArray *pages, fz_out int page = outline->dest.ld.gotor.page; if (page >= 0 && outline->title) { - NSString *title = [NSString stringWithUTF8String: outline->title]; + NSString *title = @(outline->title); [titles addObject: [NSString stringWithFormat: @"%s%@", indent, title]]; - [pages addObject: [NSNumber numberWithInt: page]]; + [pages addObject: @(page)]; } } flattenOutline(titles, pages, outline->down, level + 1); @@ -190,7 +190,7 @@ static void saveDoc(const char *current_path, fz_document *doc) else { UIView *buttonView; - BOOL iOS7Style = ([[UIDevice currentDevice].systemVersion floatValue] >= 7.0f); + BOOL iOS7Style = (([UIDevice currentDevice].systemVersion).floatValue >= 7.0f); UIButton *button = [UIButton buttonWithType:iOS7Style ? UIButtonTypeSystem : UIButtonTypeCustom]; [button setImage:[UIImage imageNamed:resource] forState:UIControlStateNormal]; [button addTarget:self action:selector forControlEvents:UIControlEventTouchUpInside]; @@ -210,8 +210,8 @@ static void saveDoc(const char *current_path, fz_document *doc) [array addObject:outlineButton]; [array addObject:reflowButton]; [array addObject:linkButton]; - [[self navigationItem] setRightBarButtonItems: array ]; - [[self navigationItem] setLeftBarButtonItem:backButton]; + self.navigationItem.rightBarButtonItems = array ; + self.navigationItem.leftBarButtonItem = backButton; } - (void) loadView @@ -223,16 +223,16 @@ static void saveDoc(const char *current_path, fz_document *doc) current = 0; UIView *view = [[UIView alloc] initWithFrame: CGRectZero]; - [view setAutoresizingMask: UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight]; + view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; [view setAutoresizesSubviews: YES]; view.backgroundColor = [UIColor grayColor]; canvas = [[UIScrollView alloc] initWithFrame: CGRectMake(0,0,GAP,0)]; - [canvas setAutoresizingMask: UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight]; + canvas.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; [canvas setPagingEnabled: YES]; [canvas setShowsHorizontalScrollIndicator: NO]; [canvas setShowsVerticalScrollIndicator: NO]; - [canvas setDelegate: self]; + canvas.delegate = self; UITapGestureRecognizer *tapRecog = [[UITapGestureRecognizer alloc] initWithTarget: self action: @selector(onTap:)]; tapRecog.delegate = self; @@ -250,27 +250,27 @@ static void saveDoc(const char *current_path, fz_document *doc) scroll_animating = NO; indicator = [[UILabel alloc] initWithFrame: CGRectZero]; - [indicator setAutoresizingMask: UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin]; - [indicator setText: @"0000 of 9999"]; + indicator.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin; + indicator.text = @"0000 of 9999"; [indicator sizeToFit]; - [indicator setCenter: CGPointMake(0, INDICATOR_Y)]; - [indicator setTextAlignment: NSTextAlignmentCenter]; - [indicator setBackgroundColor: [[UIColor blackColor] colorWithAlphaComponent: 0.5]]; - [indicator setTextColor: [UIColor whiteColor]]; + indicator.center = CGPointMake(0, INDICATOR_Y); + indicator.textAlignment = NSTextAlignmentCenter; + indicator.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent: 0.5]; + indicator.textColor = [UIColor whiteColor]; [view addSubview: canvas]; [view addSubview: indicator]; slider = [[UISlider alloc] initWithFrame: CGRectZero]; - [slider setMinimumValue: 0]; - [slider setMaximumValue: fz_count_pages(ctx, doc) - 1]; + slider.minimumValue = 0; + slider.maximumValue = fz_count_pages(ctx, doc) - 1; [slider addTarget: self action: @selector(onSlide:) forControlEvents: UIControlEventValueChanged]; - if ([[[UIDevice currentDevice] systemVersion] floatValue] < 7.0) + if ([UIDevice currentDevice].systemVersion.floatValue < 7.0) { sliderWrapper = [[UIBarButtonItem alloc] initWithCustomView: slider]; - [self setToolbarItems: [NSArray arrayWithObjects: sliderWrapper, nil]]; + self.toolbarItems = @[sliderWrapper]; } // Set up the buttons on the navigation and search bar @@ -301,8 +301,8 @@ static void saveDoc(const char *current_path, fz_document *doc) deleteButton = [self newResourceBasedButton:@"ic_trash" withAction:@selector(onDelete:)]; searchBar = [[UISearchBar alloc] initWithFrame: CGRectMake(0,0,50,32)]; backButton = [self newResourceBasedButton:@"ic_arrow_left" withAction:@selector(onBack:)]; - [searchBar setPlaceholder: @"Search"]; - [searchBar setDelegate: self]; + searchBar.placeholder = @"Search"; + searchBar.delegate = self; [prevButton setEnabled: NO]; [nextButton setEnabled: NO]; @@ -311,7 +311,7 @@ static void saveDoc(const char *current_path, fz_document *doc) // TODO: add activityindicator to search bar - [self setView: view]; + self.view = view; [view release]; } @@ -351,55 +351,55 @@ static void saveDoc(const char *current_path, fz_document *doc) - (void) viewWillAppear: (BOOL)animated { [super viewWillAppear:animated]; - [self setTitle: [key lastPathComponent]]; + self.title = key.lastPathComponent; - [slider setValue: current]; + slider.value = current; - if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) - [[[self navigationController] toolbar] addSubview:slider]; + if ([UIDevice currentDevice].systemVersion.floatValue >= 7.0) + [self.navigationController.toolbar addSubview:slider]; - [indicator setText: [NSString stringWithFormat: @" %d of %d ", current+1, fz_count_pages(ctx, doc)]]; + indicator.text = [NSString stringWithFormat: @" %d of %d ", current+1, fz_count_pages(ctx, doc)]; - [[self navigationController] setToolbarHidden: NO animated: animated]; + [self.navigationController setToolbarHidden: NO animated: animated]; } - (void) viewWillLayoutSubviews { - CGSize size = [canvas frame].size; + CGSize size = canvas.frame.size; int max_width = fz_max(width, size.width); width = size.width; height = size.height; - [canvas setContentInset: UIEdgeInsetsZero]; - [canvas setContentSize: CGSizeMake(fz_count_pages(ctx, doc) * width, height)]; - [canvas setContentOffset: CGPointMake(current * width, 0)]; + canvas.contentInset = UIEdgeInsetsZero; + canvas.contentSize = CGSizeMake(fz_count_pages(ctx, doc) * width, height); + canvas.contentOffset = CGPointMake(current * width, 0); [sliderWrapper setWidth: SLIDER_W]; - [searchBar setFrame: CGRectMake(0,0,SEARCH_W,32)]; - if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) + searchBar.frame = CGRectMake(0,0,SEARCH_W,32); + if ([UIDevice currentDevice].systemVersion.floatValue >= 7.0) { - CGRect r = [[self navigationController] toolbar].frame; + CGRect r = self.navigationController.toolbar.frame; r.origin.x = 0; r.origin.y = 0; - [slider setFrame:r]; + slider.frame = r; } - [[[self navigationController] toolbar] setNeedsLayout]; // force layout! + [self.navigationController.toolbar setNeedsLayout]; // force layout! // use max_width so we don't clamp the content offset too early during animation - [canvas setContentSize: CGSizeMake(fz_count_pages(ctx, doc) * max_width, height)]; - [canvas setContentOffset: CGPointMake(current * width, 0)]; + canvas.contentSize = CGSizeMake(fz_count_pages(ctx, doc) * max_width, height); + canvas.contentOffset = CGPointMake(current * width, 0); - for (UIView<MuPageView> *view in [canvas subviews]) { - if ([view number] == current) { - [view setFrame: CGRectMake([view number] * width, 0, width-GAP, height)]; + for (UIView<MuPageView> *view in canvas.subviews) { + if (view.number == current) { + view.frame = CGRectMake(view.number * width, 0, width-GAP, height); [view willRotate]; } } - for (UIView<MuPageView> *view in [canvas subviews]) { - if ([view number] != current) { - [view setFrame: CGRectMake([view number] * width, 0, width-GAP, height)]; + for (UIView<MuPageView> *view in canvas.subviews) { + if (view.number != current) { + view.frame = CGRectMake(view.number * width, 0, width-GAP, height); [view willRotate]; } } @@ -414,34 +414,34 @@ static void saveDoc(const char *current_path, fz_document *doc) - (void) viewWillDisappear: (BOOL)animated { [super viewWillDisappear:animated]; - if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) + if ([UIDevice currentDevice].systemVersion.floatValue >= 7.0) [slider removeFromSuperview]; - [self setTitle: @"Resume"]; + self.title = @"Resume"; [[NSUserDefaults standardUserDefaults] removeObjectForKey: @"OpenDocumentKey"]; - [[self navigationController] setToolbarHidden: YES animated: animated]; + [self.navigationController setToolbarHidden: YES animated: animated]; } - (void) showNavigationBar { - if ([[self navigationController] isNavigationBarHidden]) { + if (self.navigationController.navigationBarHidden) { [sliderWrapper setWidth: SLIDER_W]; - if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) + if ([UIDevice currentDevice].systemVersion.floatValue >= 7.0) { - CGRect r = [[self navigationController] toolbar].frame; + CGRect r = self.navigationController.toolbar.frame; r.origin.x = 0; r.origin.y = 0; - [slider setFrame:r]; + slider.frame = r; } - [[self navigationController] setNavigationBarHidden: NO]; - [[self navigationController] setToolbarHidden: NO]; + [self.navigationController setNavigationBarHidden: NO]; + [self.navigationController setToolbarHidden: NO]; [indicator setHidden: NO]; [UIView beginAnimations: @"MuNavBar" context: NULL]; - [[[self navigationController] navigationBar] setAlpha: 1]; - [[[self navigationController] toolbar] setAlpha: 1]; - [indicator setAlpha: 1]; + self.navigationController.navigationBar.alpha = 1; + self.navigationController.toolbar.alpha = 1; + indicator.alpha = 1; [UIView commitAnimations]; } @@ -449,16 +449,16 @@ static void saveDoc(const char *current_path, fz_document *doc) - (void) hideNavigationBar { - if (![[self navigationController] isNavigationBarHidden]) { + if (!self.navigationController.navigationBarHidden) { [searchBar resignFirstResponder]; [UIView beginAnimations: @"MuNavBar" context: NULL]; [UIView setAnimationDelegate: self]; [UIView setAnimationDidStopSelector: @selector(onHideNavigationBarFinished)]; - [[[self navigationController] navigationBar] setAlpha: 0]; - [[[self navigationController] toolbar] setAlpha: 0]; - [indicator setAlpha: 0]; + self.navigationController.navigationBar.alpha = 0; + self.navigationController.toolbar.alpha = 0; + indicator.alpha = 0; [UIView commitAnimations]; } @@ -466,8 +466,8 @@ static void saveDoc(const char *current_path, fz_document *doc) - (void) onHideNavigationBarFinished { - [[self navigationController] setNavigationBarHidden: YES]; - [[self navigationController] setToolbarHidden: YES]; + [self.navigationController setNavigationBarHidden: YES]; + [self.navigationController setToolbarHidden: YES]; [indicator setHidden: YES]; } @@ -481,7 +481,7 @@ static void saveDoc(const char *current_path, fz_document *doc) NSMutableArray *pages = [[NSMutableArray alloc] init]; flattenOutline(titles, pages, root, 0); [outline release]; - if ([titles count]) + if (titles.count) outline = [[MuOutlineController alloc] initWithTarget: self titles: titles pages: pages]; [titles release]; [pages release]; @@ -490,13 +490,13 @@ static void saveDoc(const char *current_path, fz_document *doc) // now show it - [[self navigationController] pushViewController: outline animated: YES]; + [self.navigationController pushViewController: outline animated: YES]; } - (void) onToggleLinks: (id)sender { showLinks = !showLinks; - for (UIView<MuPageView> *view in [canvas subviews]) + for (UIView<MuPageView> *view in canvas.subviews) { if (showLinks) [view showLinks]; @@ -509,12 +509,12 @@ static void saveDoc(const char *current_path, fz_document *doc) { reflowMode = !reflowMode; - [annotButton setEnabled:!reflowMode]; - [searchButton setEnabled:!reflowMode]; - [linkButton setEnabled:!reflowMode]; - [moreButton setEnabled:!reflowMode]; + annotButton.enabled = !reflowMode; + searchButton.enabled = !reflowMode; + linkButton.enabled = !reflowMode; + moreButton.enabled = !reflowMode; - [[canvas subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)]; + [canvas.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; [self scrollViewDidScroll:canvas]; } @@ -523,20 +523,20 @@ static void saveDoc(const char *current_path, fz_document *doc) NSMutableArray *rightbuttons = [NSMutableArray arrayWithObjects:printButton, shareButton, nil]; if (docRef->interactive) [rightbuttons insertObject:annotButton atIndex:0]; - [[self navigationItem] setRightBarButtonItems:rightbuttons]; - [[self navigationItem] setLeftBarButtonItem:cancelButton]; + self.navigationItem.rightBarButtonItems = rightbuttons; + self.navigationItem.leftBarButtonItem = cancelButton; barmode = BARMODE_MORE; } - (void) showAnnotationMenu { - [[self navigationItem] setRightBarButtonItems:[NSArray arrayWithObjects:inkButton, strikeoutButton, underlineButton, highlightButton, nil]]; - [[self navigationItem] setLeftBarButtonItem:cancelButton]; + self.navigationItem.rightBarButtonItems = @[inkButton, strikeoutButton, underlineButton, highlightButton]; + self.navigationItem.leftBarButtonItem = cancelButton; - for (UIView<MuPageView> *view in [canvas subviews]) + for (UIView<MuPageView> *view in canvas.subviews) { - if ([view number] == current) + if (view.number == current) [view deselectAnnotation]; } @@ -545,7 +545,7 @@ static void saveDoc(const char *current_path, fz_document *doc) - (void) update { - for (UIView<MuPageView> *view in [canvas subviews]) + for (UIView<MuPageView> *view in canvas.subviews) [view update]; } @@ -589,7 +589,7 @@ static void saveDoc(const char *current_path, fz_document *doc) - (void) shareDocument { NSURL *url = [NSURL fileURLWithPath:_filePath]; - UIActivityViewController *cont = [[UIActivityViewController alloc] initWithActivityItems:[NSArray arrayWithObject:url] applicationActivities:nil]; + UIActivityViewController *cont = [[UIActivityViewController alloc] initWithActivityItems:@[url] applicationActivities:nil]; cont.popoverPresentationController.barButtonItem = shareButton; [self presentViewController:cont animated:YES completion:nil]; [cont release]; @@ -612,17 +612,17 @@ static void saveDoc(const char *current_path, fz_document *doc) - (void) textSelectModeOn { - [[self navigationItem] setRightBarButtonItems:[NSArray arrayWithObject:tickButton]]; - for (UIView<MuPageView> *view in [canvas subviews]) + self.navigationItem.rightBarButtonItems = @[tickButton]; + for (UIView<MuPageView> *view in canvas.subviews) { - if ([view number] == current) + if (view.number == current) [view textSelectModeOn]; } } - (void) textSelectModeOff { - for (UIView<MuPageView> *view in [canvas subviews]) + for (UIView<MuPageView> *view in canvas.subviews) { [view textSelectModeOff]; } @@ -630,23 +630,23 @@ static void saveDoc(const char *current_path, fz_document *doc) - (void) inkModeOn { - [[self navigationItem] setRightBarButtonItems:[NSArray arrayWithObject:tickButton]]; - for (UIView<MuPageView> *view in [canvas subviews]) + self.navigationItem.rightBarButtonItems = @[tickButton]; + for (UIView<MuPageView> *view in canvas.subviews) { - if ([view number] == current) + if (view.number == current) [view inkModeOn]; } } - (void) deleteModeOn { - [[self navigationItem] setRightBarButtonItems:[NSArray arrayWithObject:deleteButton]]; + self.navigationItem.rightBarButtonItems = @[deleteButton]; barmode = BARMODE_DELETE; } - (void) inkModeOff { - for (UIView<MuPageView> *view in [canvas subviews]) + for (UIView<MuPageView> *view in canvas.subviews) { [view inkModeOff]; } @@ -678,10 +678,9 @@ static void saveDoc(const char *current_path, fz_document *doc) - (void) onShowSearch: (id)sender { - [[self navigationItem] setRightBarButtonItems: - [NSArray arrayWithObjects: nextButton, prevButton, nil]]; - [[self navigationItem] setLeftBarButtonItem: cancelButton]; - [[self navigationItem] setTitleView: searchBar]; + self.navigationItem.rightBarButtonItems = @[nextButton, prevButton]; + self.navigationItem.leftBarButtonItem = cancelButton; + self.navigationItem.titleView = searchBar; [searchBar becomeFirstResponder]; barmode = BARMODE_SEARCH; } @@ -689,9 +688,9 @@ static void saveDoc(const char *current_path, fz_document *doc) - (void) onTick: (id)sender { - for (UIView<MuPageView> *view in [canvas subviews]) + for (UIView<MuPageView> *view in canvas.subviews) { - if ([view number] == current) + if (view.number == current) { switch (barmode) { @@ -718,9 +717,9 @@ static void saveDoc(const char *current_path, fz_document *doc) - (void) onDelete: (id)sender { - for (UIView<MuPageView> *view in [canvas subviews]) + for (UIView<MuPageView> *view in canvas.subviews) { - if ([view number] == current) + if (view.number == current) [view deleteSelectedAnnotation]; } [self showAnnotationMenu]; @@ -737,7 +736,7 @@ static void saveDoc(const char *current_path, fz_document *doc) /* fallthrough */ case BARMODE_ANNOTATION: case BARMODE_MORE: - [[self navigationItem] setTitleView: nil]; + [self.navigationItem setTitleView: nil]; [self addMainMenuButtons]; barmode = BARMODE_MAIN; break; @@ -770,7 +769,7 @@ static void saveDoc(const char *current_path, fz_document *doc) } else { - [[self navigationController] popViewControllerAnimated:YES]; + [self.navigationController popViewControllerAnimated:YES]; } } @@ -782,7 +781,7 @@ static void saveDoc(const char *current_path, fz_document *doc) saveDoc(_filePath.UTF8String, doc); [alertView dismissWithClickedButtonIndex:buttonIndex animated:YES]; - [[self navigationController] popViewControllerAnimated:YES]; + [self.navigationController popViewControllerAnimated:YES]; } if ([ShareAlertMessage isEqualToString:alertView.message]) @@ -799,7 +798,7 @@ static void saveDoc(const char *current_path, fz_document *doc) - (void) resetSearch { searchPage = -1; - for (UIView<MuPageView> *view in [canvas subviews]) + for (UIView<MuPageView> *view in canvas.subviews) [view clearSearchResults]; } @@ -808,8 +807,8 @@ static void saveDoc(const char *current_path, fz_document *doc) printf("search found match on page %d\n", number); searchPage = number; [self gotoPage: number animated: NO]; - for (UIView<MuPageView> *view in [canvas subviews]) - if ([view number] == number) + for (UIView<MuPageView> *view in canvas.subviews) + if (view.number == number) [view showSearchResults: count]; else [view clearSearchResults]; @@ -828,10 +827,10 @@ static void saveDoc(const char *current_path, fz_document *doc) else start = current; - needle = strdup([[searchBar text] UTF8String]); + needle = strdup(searchBar.text.UTF8String); searchField = nil; - for (id view in [searchBar subviews]) + for (id view in searchBar.subviews) if ([view isKindOfClass: [UITextField class]]) searchField = view; @@ -871,7 +870,7 @@ static void saveDoc(const char *current_path, fz_document *doc) [searchField setEnabled: YES]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"No matches found for:" - message: [NSString stringWithUTF8String: needle] + message: @(needle) delegate: nil cancelButtonTitle: @"Close" otherButtonTitles: nil]; @@ -900,7 +899,7 @@ static void saveDoc(const char *current_path, fz_document *doc) - (void) searchBar: (UISearchBar*)sender textDidChange: (NSString*)searchText { [self resetSearch]; - if ([[searchBar text] length] > 0) { + if (searchBar.text.length > 0) { [prevButton setEnabled: YES]; [nextButton setEnabled: YES]; } else { @@ -911,9 +910,9 @@ static void saveDoc(const char *current_path, fz_document *doc) - (void) onSlide: (id)sender { - int number = [slider value]; - if ([slider isTracking]) - [indicator setText: [NSString stringWithFormat: @" %d of %d ", number+1, fz_count_pages(ctx, doc)]]; + int number = slider.value; + if (slider.tracking) + indicator.text = [NSString stringWithFormat: @" %d of %d ", number+1, fz_count_pages(ctx, doc)]; else [self gotoPage: number animated: NO]; } @@ -928,13 +927,13 @@ static void saveDoc(const char *current_path, fz_document *doc) - (void) onTap: (UITapGestureRecognizer*)sender { CGPoint p = [sender locationInView: canvas]; - CGPoint ofs = [canvas contentOffset]; + CGPoint ofs = canvas.contentOffset; float x0 = (width - GAP) / 5; float x1 = (width - GAP) - x0; p.x -= ofs.x; p.y -= ofs.y; __block BOOL tapHandled = NO; - for (UIView<MuPageView> *view in [canvas subviews]) + for (UIView<MuPageView> *view in canvas.subviews) { CGPoint pp = [sender locationInView:view]; if (CGRectContainsPoint(view.bounds, pp)) @@ -989,7 +988,7 @@ static void saveDoc(const char *current_path, fz_document *doc) } else if (p.x > x1) { [self gotoPage: current+1 animated: YES]; } else { - if ([[self navigationController] isNavigationBarHidden]) + if (self.navigationController.navigationBarHidden) [self showNavigationBar]; else if (barmode == BARMODE_MAIN) [self hideNavigationBar]; @@ -1010,7 +1009,7 @@ static void saveDoc(const char *current_path, fz_document *doc) if (sender.state == UIGestureRecognizerStateEnded) scale = sender.scale; - for (UIView<MuPageView> *view in [canvas subviews]) + for (UIView<MuPageView> *view in canvas.subviews) { // Zoom only the visible page until end of gesture if (view.number == current || sender.state == UIGestureRecognizerStateEnded) @@ -1042,21 +1041,21 @@ static void saveDoc(const char *current_path, fz_document *doc) if (scroll_animating) return; // don't mess with layout during animations - float x = [canvas contentOffset].x + width * 0.5f; + float x = canvas.contentOffset.x + width * 0.5f; current = x / width; [[NSUserDefaults standardUserDefaults] setInteger: current forKey: key]; - [indicator setText: [NSString stringWithFormat: @" %d of %d ", current+1, fz_count_pages(ctx, doc)]]; - [slider setValue: current]; + indicator.text = [NSString stringWithFormat: @" %d of %d ", current+1, fz_count_pages(ctx, doc)]; + slider.value = current; // swap the distant page views out NSMutableSet *invisiblePages = [[NSMutableSet alloc] init]; - for (UIView<MuPageView> *view in [canvas subviews]) { - if ([view number] != current) + for (UIView<MuPageView> *view in canvas.subviews) { + if (view.number != current) [view resetZoomAnimated: YES]; - if ([view number] < current - 2 || [view number] > current + 2) + if (view.number < current - 2 || view.number > current + 2) [invisiblePages addObject: view]; } for (UIView<MuPageView> *view in invisiblePages) @@ -1077,8 +1076,8 @@ static void saveDoc(const char *current_path, fz_document *doc) if (number < 0 || number >= fz_count_pages(ctx, doc)) return; int found = 0; - for (UIView<MuPageView> *view in [canvas subviews]) - if ([view number] == number) + for (UIView<MuPageView> *view in canvas.subviews) + if (view.number == number) found = 1; if (!found) { UIView<MuPageView> *view @@ -1116,18 +1115,18 @@ static void saveDoc(const char *current_path, fz_document *doc) [UIView setAnimationDelegate: self]; [UIView setAnimationDidStopSelector: @selector(onGotoPageFinished)]; - for (UIView<MuPageView> *view in [canvas subviews]) + for (UIView<MuPageView> *view in canvas.subviews) [view resetZoomAnimated: NO]; - [canvas setContentOffset: CGPointMake(number * width, 0)]; - [slider setValue: number]; - [indicator setText: [NSString stringWithFormat: @" %d of %d ", number+1, fz_count_pages(ctx, doc)]]; + canvas.contentOffset = CGPointMake(number * width, 0); + slider.value = number; + indicator.text = [NSString stringWithFormat: @" %d of %d ", number+1, fz_count_pages(ctx, doc)]; [UIView commitAnimations]; } else { - for (UIView<MuPageView> *view in [canvas subviews]) + for (UIView<MuPageView> *view in canvas.subviews) [view resetZoomAnimated: NO]; - [canvas setContentOffset: CGPointMake(number * width, 0)]; + canvas.contentOffset = CGPointMake(number * width, 0); } current = number; } @@ -1171,8 +1170,8 @@ static void saveDoc(const char *current_path, fz_document *doc) // We need to set these here, because during the animation we may use a wider // size (the maximum of the landscape/portrait widths), to avoid clipping during // the rotation. - [canvas setContentSize: CGSizeMake(fz_count_pages(ctx, doc) * width, height)]; - [canvas setContentOffset: CGPointMake(current * width, 0)]; + canvas.contentSize = CGSizeMake(fz_count_pages(ctx, doc) * width, height); + canvas.contentOffset = CGPointMake(current * width, 0); } @end diff --git a/platform/ios/Classes/MuHitView.m b/platform/ios/Classes/MuHitView.m index 2709f829..e94ac94a 100644 --- a/platform/ios/Classes/MuHitView.m +++ b/platform/ios/Classes/MuHitView.m @@ -83,7 +83,7 @@ } if (linkUrl[i]) { - NSString *url = [NSString stringWithUTF8String:linkUrl[i]]; + NSString *url = @(linkUrl[i]); return [[[MuTapResultExternalLink alloc] initWithUrl:url] autorelease]; } } diff --git a/platform/ios/Classes/MuInkView.m b/platform/ios/Classes/MuInkView.m index 78bc73df..75799941 100644 --- a/platform/ios/Classes/MuInkView.m +++ b/platform/ios/Classes/MuInkView.m @@ -42,7 +42,7 @@ if (rec.state == UIGestureRecognizerStateBegan) [curves addObject:[NSMutableArray array]]; - NSMutableArray *curve = [curves lastObject]; + NSMutableArray *curve = curves.lastObject; [curve addObject:[NSValue valueWithCGPoint:p]]; [self setNeedsDisplay]; @@ -61,14 +61,14 @@ { if (curve.count >= 2) { - CGPoint pt = [[curve objectAtIndex:0] CGPointValue]; + CGPoint pt = [curve[0] CGPointValue]; CGContextBeginPath(cref); CGContextMoveToPoint(cref, pt.x, pt.y); CGPoint lpt = pt; for (int i = 1; i < curve.count; i++) { - pt = [[curve objectAtIndex:i] CGPointValue]; + pt = [curve[i] CGPointValue]; CGContextAddQuadCurveToPoint(cref, lpt.x, lpt.y, (pt.x + lpt.x)/2, (pt.y + lpt.y)/2); lpt = pt; } 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]; diff --git a/platform/ios/Classes/MuOutlineController.m b/platform/ios/Classes/MuOutlineController.m index edddbd8f..26bda59a 100644 --- a/platform/ios/Classes/MuOutlineController.m +++ b/platform/ios/Classes/MuOutlineController.m @@ -12,11 +12,11 @@ { self = [super initWithStyle: UITableViewStylePlain]; if (self) { - [self setTitle: @"Table of Contents"]; + self.title = @"Table of Contents"; target = aTarget; // only keep a weak reference, to avoid retain cycles titles = [aTitles retain]; pages = [aPages retain]; - [[self tableView] setSeparatorStyle: UITableViewCellSeparatorStyleNone]; + self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; } return self; } @@ -40,7 +40,7 @@ - (NSInteger) tableView: (UITableView*)tableView numberOfRowsInSection: (NSInteger)section { - return [titles count]; + return titles.count; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath @@ -55,21 +55,21 @@ if (!cell) { cell = [[[UITableViewCell alloc] initWithStyle: UITableViewCellStyleValue1 reuseIdentifier: cellid] autorelease]; - [[cell textLabel] setFont: [UIFont systemFontOfSize: 16]]; - [[cell detailTextLabel] setFont: [UIFont systemFontOfSize: 16]]; + cell.textLabel.font = [UIFont systemFontOfSize: 16]; + cell.detailTextLabel.font = [UIFont systemFontOfSize: 16]; } - NSString *title = [titles objectAtIndex: [indexPath row]]; - NSString *page = [pages objectAtIndex: [indexPath row]]; - [[cell textLabel] setText: title]; - [[cell detailTextLabel] setText: [NSString stringWithFormat: @"%d", [page intValue]+1]]; + NSString *title = titles[indexPath.row]; + NSString *page = pages[indexPath.row]; + cell.textLabel.text = title; + cell.detailTextLabel.text = [NSString stringWithFormat: @"%d", page.intValue+1]; return cell; } - (void) tableView: (UITableView*)tableView didSelectRowAtIndexPath: (NSIndexPath*)indexPath { - NSNumber *page = [pages objectAtIndex: [indexPath row]]; - [target gotoPage: [page intValue] animated: NO]; - [[self navigationController] popViewControllerAnimated: YES]; + NSNumber *page = pages[indexPath.row]; + [target gotoPage: page.intValue animated: NO]; + [self.navigationController popViewControllerAnimated: YES]; } @end diff --git a/platform/ios/Classes/MuPageViewNormal.m b/platform/ios/Classes/MuPageViewNormal.m index d40ef0e1..e60f006d 100644 --- a/platform/ios/Classes/MuPageViewNormal.m +++ b/platform/ios/Classes/MuPageViewNormal.m @@ -131,7 +131,7 @@ static NSArray *enumerateWords(fz_document *doc, fz_page *page) if (word.string.length > 0) [wds addObject:word]; - if ([wds count] > 0) + if (wds.count > 0) [lns addObject:wds]; } } @@ -203,7 +203,7 @@ static void addMarkupAnnot(fz_document *doc, fz_page *page, int type, NSArray *r quadpts = fz_malloc_array(ctx, (int)rects.count * 4, sizeof(fz_point)); for (i = 0; i < rects.count; i++) { - CGRect rect = [[rects objectAtIndex:i] CGRectValue]; + CGRect rect = [rects[i] CGRectValue]; float top = rect.origin.y; float bot = top + rect.size.height; float left = rect.origin.x; @@ -258,7 +258,7 @@ static void addInkAnnot(fz_document *doc, fz_page *page, NSArray *curves) for (i = 0; i < n; i++) { - NSArray *curve = [curves objectAtIndex:i]; + NSArray *curve = curves[i]; counts[i] = (int)curve.count; total += (int)curve.count; } @@ -268,12 +268,12 @@ static void addInkAnnot(fz_document *doc, fz_page *page, NSArray *curves) k = 0; for (i = 0; i < n; i++) { - NSArray *curve = [curves objectAtIndex:i]; + NSArray *curve = curves[i]; int count = counts[i]; for (j = 0; j < count; j++) { - CGPoint pt = [[curve objectAtIndex:j] CGPointValue]; + CGPoint pt = [curve[j] CGPointValue]; pts[k].x = pt.x; pts[k].y = pt.y; k++; @@ -655,8 +655,8 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa [self setShowsVerticalScrollIndicator: NO]; [self setShowsHorizontalScrollIndicator: NO]; - [self setDecelerationRate: UIScrollViewDecelerationRateFast]; - [self setDelegate: self]; + self.decelerationRate = UIScrollViewDecelerationRateFast; + self.delegate = self; // zoomDidFinish/Begin events fire before bounce animation completes, // making a mess when we rearrange views during the animation. @@ -731,7 +731,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa fz_drop_link(ctx, links); }); if (imageView) { - [linkView setFrame: [imageView frame]]; + linkView.frame = imageView.frame; [linkView setPageSize: pageSize]; } [self addSubview: linkView]; @@ -756,7 +756,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa } hitView = [[MuHitView alloc] initWithSearchResults: count forDocument: doc]; if (imageView) { - [hitView setFrame: [imageView frame]]; + hitView.frame = imageView.frame; [hitView setPageSize: pageSize]; } [self addSubview: hitView]; @@ -780,7 +780,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa textSelectView = [[MuTextSelectView alloc] initWithWords:words pageSize:pageSize]; [words release]; if (imageView) - [textSelectView setFrame:[imageView frame]]; + textSelectView.frame = imageView.frame; [self addSubview:textSelectView]; }); }); @@ -790,7 +790,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa { inkView = [[MuInkView alloc] initWithPageSize:pageSize]; if (imageView) - [inkView setFrame:[imageView frame]]; + inkView.frame = imageView.frame; [self addSubview:inkView]; } @@ -810,7 +810,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa -(void) saveSelectionAsMarkup:(int)type { - NSArray *rects = [textSelectView selectionRects]; + NSArray *rects = textSelectView.selectionRects; if (rects.count == 0) return; @@ -851,7 +851,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa selectedAnnotationIndex = i; [annotSelectView removeFromSuperview]; [annotSelectView release]; - annotSelectView = [[MuAnnotSelectView alloc] initWithAnnot:[annotations objectAtIndex:i] pageSize:pageSize]; + annotSelectView = [[MuAnnotSelectView alloc] initWithAnnot:annotations[i] pageSize:pageSize]; [self addSubview:annotSelectView]; } @@ -890,8 +890,8 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa tileView = nil; } - [self setMinimumZoomScale: 1]; - [self setMaximumZoomScale: 5]; + self.minimumZoomScale = 1; + self.maximumZoomScale = 5; [self setZoomScale: 1 animated: animated]; } @@ -963,7 +963,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa if (annotSelectView) [self bringSubviewToFront:annotSelectView]; } else { - [imageView setImage: image]; + imageView.image = image; } [self resizeImage]; @@ -975,10 +975,10 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa CGSize imageSize = imageView.image.size; CGSize scale = fitPageToScreen(imageSize, self.bounds.size); if (fabs(scale.width - 1) > 0.1) { - CGRect frame = [imageView frame]; + CGRect frame = imageView.frame; frame.size.width = imageSize.width * scale.width; frame.size.height = imageSize.height * scale.height; - [imageView setFrame: frame]; + imageView.frame = frame; printf("resized view; queuing up a reload (%d)\n", number); dispatch_async(queue, ^{ @@ -992,7 +992,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa [imageView sizeToFit]; } - [self setContentSize: imageView.frame.size]; + self.contentSize = imageView.frame.size; [self layoutIfNeeded]; } @@ -1035,22 +1035,22 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa if (imageView) { - CGRect frm = [imageView frame]; + CGRect frm = imageView.frame; if (hitView) - [hitView setFrame: frm]; + hitView.frame = frm; if (linkView) - [linkView setFrame:frm]; + linkView.frame = frm; if (textSelectView) - [textSelectView setFrame:frm]; + textSelectView.frame = frm; if (inkView) - [inkView setFrame:frm]; + inkView.frame = frm; if (annotSelectView) - [annotSelectView setFrame:frm]; + annotSelectView.frame = frm; } } @@ -1107,7 +1107,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa } tileView = [[UIImageView alloc] initWithFrame: frame]; - [tileView setImage: image]; + tileView.image = image; [self addSubview: tileView]; if (hitView) [self bringSubviewToFront: hitView]; @@ -1157,19 +1157,19 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa { if (imageView) { - CGRect frm = [imageView frame]; + CGRect frm = imageView.frame; if (hitView) - [hitView setFrame: frm]; + hitView.frame = frm; if (textSelectView) - [textSelectView setFrame:frm]; + textSelectView.frame = frm; if (inkView) - [inkView setFrame:frm]; + inkView.frame = frm; if (annotSelectView) - [annotSelectView setFrame:frm]; + annotSelectView.frame = frm; } } @@ -1187,7 +1187,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa dispatch_async(dispatch_get_main_queue(), ^{ BOOL isValid = CGRectEqualToRect(tframe, tileFrame) && tscale == tileScale; if (isValid) - [tileView setImage:timage]; + tileView.image = timage; [timage release]; }); } @@ -1197,7 +1197,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa drop_list(rlist); UIImage *image = newImageWithPixmap(image_pix, imageData); dispatch_async(dispatch_get_main_queue(), ^{ - [imageView setImage:image]; + imageView.image = image; [image release]; }); } @@ -1219,7 +1219,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa { [dialogCreator invokeTextDialog:text okayAction:^(NSString *newText) { dispatch_async(queue, ^{ - BOOL accepted = setFocussedWidgetText(doc, page, [newText UTF8String]); + BOOL accepted = setFocussedWidgetText(doc, page, newText.UTF8String); if (accepted) { dispatch_async(dispatch_get_main_queue(), ^{ @@ -1240,7 +1240,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa { [dialogCreator invokeChoiceDialog:choices okayAction:^(NSArray *selection) { dispatch_async(queue, ^{ - BOOL accepted = setFocussedWidgetChoice(doc, page, [[selection objectAtIndex:0] UTF8String]); + BOOL accepted = setFocussedWidgetChoice(doc, page, [selection[0] UTF8String]); if (accepted) { dispatch_async(dispatch_get_main_queue(), ^{ @@ -1290,7 +1290,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa case PDF_WIDGET_TYPE_TEXT: { text = pdf_text_widget_text(ctx, idoc, focus); - NSString *stext = [[NSString stringWithUTF8String:text?text:""] retain]; + NSString *stext = [@(text?text:"") retain]; dispatch_async(dispatch_get_main_queue(), ^{ [self invokeTextDialog:stext]; [stext release]; @@ -1307,10 +1307,10 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa NSMutableArray *arr = [[NSMutableArray arrayWithCapacity:nopts] retain]; for (int i = 0; i < nopts; i++) { - NSString *utf8 = [NSString stringWithUTF8String:opts[i]]; + NSString *utf8 = @(opts[i]); // FIXME: temporary patch to handle the library not converting to utf8 if (utf8 == nil) - utf8 = [NSString stringWithCString:opts[i] encoding:NSASCIIStringEncoding]; + utf8 = @(opts[i]); if (utf8 != nil) [arr addObject:utf8]; } @@ -1352,7 +1352,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa for (i = 0; i < annotations.count; i++) { - MuAnnotation *annot = [annotations objectAtIndex:i]; + MuAnnotation *annot = annotations[i]; if (annot.type != FZ_ANNOT_WIDGET && CGRectContainsPoint(annot.rect, ipt)) { [self selectAnnotation:i]; @@ -1364,7 +1364,7 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa for (i = 0; i < widgetRects.count; i++) { - CGRect r = [[widgetRects objectAtIndex:i] CGRectValue]; + CGRect r = [widgetRects[i] CGRectValue]; if (CGRectContainsPoint(r, ipt)) { dispatch_async(queue, ^{ diff --git a/platform/ios/Classes/MuPageViewReflow.m b/platform/ios/Classes/MuPageViewReflow.m index 554a8f30..9378da61 100644 --- a/platform/ios/Classes/MuPageViewReflow.m +++ b/platform/ios/Classes/MuPageViewReflow.m @@ -85,7 +85,7 @@ NSString *textAsHtml(fz_document *doc, int pageNum) number = aNumber; scale = 1.0; self.scalesPageToFit = NO; - [self setDelegate:self]; + self.delegate = self; dispatch_async(queue, ^{ __block NSString *cont = [textAsHtml(aDoc->doc, aNumber) retain]; dispatch_async(dispatch_get_main_queue(), ^{ diff --git a/platform/ios/Classes/MuWord.m b/platform/ios/Classes/MuWord.m index 4adae1d7..cd05e23b 100644 --- a/platform/ios/Classes/MuWord.m +++ b/platform/ios/Classes/MuWord.m @@ -53,7 +53,7 @@ for (NSArray *line in words) { - MuWord *fst = [line objectAtIndex:0]; + MuWord *fst = line[0]; float ltop = fst.rect.origin.y; float lbot = ltop + fst.rect.size.height; diff --git a/platform/ios/main.m b/platform/ios/main.m index dd2bc30e..6a2c570c 100644 --- a/platform/ios/main.m +++ b/platform/ios/main.m @@ -9,7 +9,7 @@ int main(int argc, char *argv[]) } @catch (NSException* exception) { NSLog(@"Uncaught exception %@", exception); - NSLog(@"Stack trace: %@", [exception callStackSymbols]); + NSLog(@"Stack trace: %@", exception.callStackSymbols); } return 0; |