Skip to content
Browse files

convert to literals + subscripting

  • Loading branch information...
1 parent c8e01d2 commit 8789b2a2294e2adda5ad985edb4bc07fc5c51f5c @steipete committed Jun 13, 2012
View
6 Examples/PSPDFKitExample/AppDelegate.m
@@ -40,10 +40,10 @@ - (void)addCustomLocalization {
// prepare the dictionary structure (here, we only add en, which is the fallback)
NSMutableDictionary *localizationDict = [NSMutableDictionary dictionaryWithCapacity:1];
NSMutableDictionary *enLocalizationDict = [NSMutableDictionary dictionaryWithCapacity:1];
- [localizationDict setObject:enLocalizationDict forKey:@"en"];
+ localizationDict[@"en"] = enLocalizationDict;
// add localization content
- [enLocalizationDict setObject:@"Magazines" forKey:@"Documents"];
+ enLocalizationDict[@"Documents"] = @"Magazines";
PSPDFSetLocalizationDictionary(localizationDict);
}
@@ -90,7 +90,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
window_.rootViewController = navigationController_;
[window_ makeKeyAndVisible];
- NSString *cacheFolder = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];
+ NSString *cacheFolder = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0];
PSELog(@"CacheDir: %@", cacheFolder);
// set white status bar style when not on ipad
View
4 Examples/PSPDFKitExample/Categories/NSObject+BlockObservation.m
@@ -93,7 +93,7 @@ - (AMBlockToken *)addObserverForKeyPath:(NSString *)keyPath onQueue:(NSOperation
[dict release];
}
AMObserverTrampoline *trampoline = [[AMObserverTrampoline alloc] initObservingObject:self keyPath:keyPath onQueue:queue task:task];
- [dict setObject:trampoline forKey:token];
+ dict[token] = trampoline;
[trampoline release];
});
return token;
@@ -102,7 +102,7 @@ - (AMBlockToken *)addObserverForKeyPath:(NSString *)keyPath onQueue:(NSOperation
- (void)removeObserverWithBlockToken:(AMBlockToken *)token {
dispatch_sync(AMObserverMutationQueueCreatingIfNecessary(), ^{
NSMutableDictionary *observationDictionary = objc_getAssociatedObject(self, AMObserverMapKey);
- AMObserverTrampoline *trampoline = [observationDictionary objectForKey:token];
+ AMObserverTrampoline *trampoline = observationDictionary[token];
if (!trampoline)
{
NSLog(@"[NSObject(AMBlockObservation) removeObserverWithBlockToken]: Ignoring attempt to remove non-existent observer on %@ for token %@.", self, token);
View
2 Examples/PSPDFKitExample/PSActionSheet.m
@@ -86,7 +86,7 @@ - (void)showFromRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animated
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
// Run the button's block
if (buttonIndex >= 0 && buttonIndex < [blocks_ count]) {
- id obj = [blocks_ objectAtIndex:buttonIndex];
+ id obj = blocks_[buttonIndex];
if (![obj isEqual:[NSNull null]]) {
((void (^)())obj)();
}
View
2 Examples/PSPDFKitExample/PSPDFDownload.m
@@ -157,7 +157,7 @@ - (void)startDownload {
[pdfRequest startAsynchronous];
self.request = pdfRequest; // save request
- [[PSPDFStoreManager sharedPSPDFStoreManager] addMagazinesToStore:[NSArray arrayWithObject:self.magazine]];
+ [[PSPDFStoreManager sharedPSPDFStoreManager] addMagazinesToStore:@[self.magazine]];
}
- (void)cancelDownload {
View
14 Examples/PSPDFKitExample/PSPDFExampleViewController.m
@@ -32,7 +32,7 @@ - (void)optionsButtonPressed:(id)sender {
PSPDFSettingsController *cacheSettingsController = [[PSPDFSettingsController alloc] init];
if (PSIsIpad()) {
self.popoverController = [[UIPopoverController alloc] initWithContentViewController:cacheSettingsController];
- self.popoverController.passthroughViews = [NSArray arrayWithObject:self.navigationController.navigationBar];
+ self.popoverController.passthroughViews = @[self.navigationController.navigationBar];
[self.popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}else {
[self presentModalViewController:cacheSettingsController withCloseButton:YES animated:YES];
@@ -66,7 +66,7 @@ - (void)globalVarChanged {
self.rightBarButtonItems = rightBarButtonItems;
// define additional buttons with an action icon
- self.additionalRightBarButtonItems = [NSArray arrayWithObjects:self.printButtonItem, self.openInButtonItem, self.emailButtonItem, nil];
+ self.additionalRightBarButtonItems = @[self.printButtonItem, self.openInButtonItem, self.emailButtonItem];
NSUInteger page = [self landscapePage:self.page];
self.pageMode = [PSPDFSettingsController pageMode];
@@ -100,10 +100,10 @@ - (id)initWithDocument:(PSPDFDocument *)document {
// 1.10 feature: replaces printEnabled, openInEnabled
if (PSIsIpad()) {
- self.additionalRightBarButtonItems = [NSArray arrayWithObjects:self.openInButtonItem, self.printButtonItem, self.emailButtonItem, nil];
+ self.additionalRightBarButtonItems = @[self.openInButtonItem, self.printButtonItem, self.emailButtonItem];
}else {
- self.rightBarButtonItems = [NSArray arrayWithObjects:self.searchButtonItem, self.viewModeButtonItem, nil];
- self.additionalRightBarButtonItems = [NSArray arrayWithObjects:self.openInButtonItem, self.printButtonItem, self.emailButtonItem, self.outlineButtonItem, nil];
+ self.rightBarButtonItems = @[self.searchButtonItem, self.viewModeButtonItem];
+ self.additionalRightBarButtonItems = @[self.openInButtonItem, self.printButtonItem, self.emailButtonItem, self.outlineButtonItem];
}
// don't clip pages that have a high aspect ration variance. (for pageCurl, optional but useful check)
@@ -115,8 +115,8 @@ - (id)initWithDocument:(PSPDFDocument *)document {
UIBarButtonItem *closeButtonItem = [[UIBarButtonItem alloc] initWithTitle:closeTitle style:UIBarButtonItemStyleBordered target:self action:@selector(close:)];
PSPDFSettingsBarButtonItem *settingsButtomItem = [[PSPDFSettingsBarButtonItem alloc] initWithPDFViewController:self];
- self.leftBarButtonItems = [NSArray arrayWithObjects:closeButtonItem, settingsButtomItem, nil];
- self.barButtonItemsAlwaysEnabled = [NSArray arrayWithObject:closeButtonItem];
+ self.leftBarButtonItems = @[closeButtonItem, settingsButtomItem];
+ self.barButtonItemsAlwaysEnabled = @[closeButtonItem];
// restore viewState
if ([self.document isValid]) {
View
16 Examples/PSPDFKitExample/PSPDFGridController.m
@@ -243,7 +243,7 @@ - (void)viewDidLoad {
action:@selector(optionsButtonPressed)];
// only show the option button if we're at root (else we hide the back button)
- if ([self.navigationController.viewControllers objectAtIndex:0] == self) {
+ if ((self.navigationController.viewControllers)[0] == self) {
self.navigationItem.leftBarButtonItem = optionButton;
}else {
// iOS5 supports easy additional buttons next to a native back button
@@ -428,9 +428,9 @@ - (PSPDFGridViewCell *)PSPDFGridView:(PSPDFGridView *)gridView cellForItemAtInde
}
if (self.magazineFolder) {
- cell.magazine = (PSPDFMagazine *)[self.magazineFolder.magazines objectAtIndex:cellIndex];
+ cell.magazine = (PSPDFMagazine *)(self.magazineFolder.magazines)[cellIndex];
}else {
- cell.magazineFolder = [[PSPDFStoreManager sharedPSPDFStoreManager].magazineFolders objectAtIndex:cellIndex];
+ cell.magazineFolder = ([PSPDFStoreManager sharedPSPDFStoreManager].magazineFolders)[cellIndex];
}
return cell;
@@ -442,7 +442,7 @@ - (BOOL)PSPDFGridView:(PSPDFGridView *)gridView canDeleteItemAtIndex:(NSInteger)
NSArray *fixedMagazines = [self.magazineFolder.magazines filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"isDeletable = NO || isAvailable = NO || isDownloading = YES"]];
canDelete = [fixedMagazines count] == 0;
}else {
- PSPDFMagazine *magazine = [self.magazineFolder.magazines objectAtIndex:index];
+ PSPDFMagazine *magazine = (self.magazineFolder.magazines)[index];
canDelete = magazine.isAvailable && !magazine.isDownloading && magazine.isDeletable;
}
return canDelete;
@@ -454,9 +454,9 @@ - (void)PSPDFGridView:(PSPDFGridView *)gridView processDeleteActionForItemAtInde
if (self.magazineFolder) {
folder = self.magazineFolder;
- magazine = [self.magazineFolder.magazines objectAtIndex:index];
+ magazine = (self.magazineFolder.magazines)[index];
}else {
- folder = [[PSPDFStoreManager sharedPSPDFStoreManager].magazineFolders objectAtIndex:index];
+ folder = ([PSPDFStoreManager sharedPSPDFStoreManager].magazineFolders)[index];
magazine = [folder firstMagazine];
}
@@ -513,9 +513,9 @@ - (void)PSPDFGridView:(PSPDFGridView *)gridView didTapOnItemAtIndex:(NSInteger)g
if (self.magazineFolder) {
folder = self.magazineFolder;
- magazine = [self.magazineFolder.magazines objectAtIndex:gridIndex];
+ magazine = (self.magazineFolder.magazines)[gridIndex];
}else {
- folder = [[PSPDFStoreManager sharedPSPDFStoreManager].magazineFolders objectAtIndex:gridIndex];
+ folder = ([PSPDFStoreManager sharedPSPDFStoreManager].magazineFolders)[gridIndex];
magazine = [folder firstMagazine];
}
View
4 Examples/PSPDFKitExample/PSPDFMagazineFolder.m
@@ -79,7 +79,7 @@ - (BOOL)isSingleMagazine {
}
- (PSPDFMagazine *)firstMagazine {
- PSPDFMagazine *firstMagazine = [self.magazines count] ? [self.magazines objectAtIndex:0] : nil;
+ PSPDFMagazine *firstMagazine = [self.magazines count] ? (self.magazines)[0] : nil;
return firstMagazine;
}
@@ -96,7 +96,7 @@ - (void)removeMagazine:(PSPDFMagazine *)magazine {
}
- (void)sortMagazines {
- [magazines_ sortUsingDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"uid" ascending:NO]]];
+ [magazines_ sortUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"uid" ascending:NO]]];
}
- (void)setMagazines:(NSArray *)magazines {
View
16 Examples/PSPDFKitExample/PSPDFSettingsController.m
@@ -49,12 +49,12 @@ - (id)initWithStyle:(UITableViewStyle)style {
self.title = _(@"Options");
content_ = [[NSArray alloc] initWithObjects:
- [NSArray arrayWithObjects:_(@"No Disk Cache"), _(@"Thumbnails & near Pages"), _(@"Cache everything"), nil],
- [NSArray arrayWithObjects:_(@"Horizontal (Magazine style)"), _(@"Vertical (like UIWebView)"), _(@"PageCurl (like iBooks, iOS5)"), nil],
- [NSArray arrayWithObjects:_(@"Single Page"), _(@"Double Pages"), _(@"Automatic on Rotation"), nil],
- [NSArray arrayWithObjects:_(@"Single First Page (Cover)"), _(@"No Cover Page"), nil],
- [NSArray arrayWithObjects:_(@"Zoom small files"), _(@"Zoom to width"), _(@"Scrobblebar"), nil], // @"Paging Enabled"
- [NSArray arrayWithObjects:_(@"Search"), _(@"Outline"), _(@"Annotations"), _(@"AspectRatio Equal"), _(@"Two Step Rendering"), nil],
+ @[_(@"No Disk Cache"), _(@"Thumbnails & near Pages"), _(@"Cache everything")],
+ @[_(@"Horizontal (Magazine style)"), _(@"Vertical (like UIWebView)"), _(@"PageCurl (like iBooks, iOS5)")],
+ @[_(@"Single Page"), _(@"Double Pages"), _(@"Automatic on Rotation")],
+ @[_(@"Single First Page (Cover)"), _(@"No Cover Page")],
+ @[_(@"Zoom small files"), _(@"Zoom to width"), _(@"Scrobblebar")], // @"Paging Enabled"
+ @[_(@"Search"), _(@"Outline"), _(@"Annotations"), _(@"AspectRatio Equal"), _(@"Two Step Rendering")],
nil];
}
return self;
@@ -180,7 +180,7 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return [[content_ objectAtIndex:section] count];
+ return [content_[section] count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
@@ -191,7 +191,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
- cell.textLabel.text = [[content_ objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
+ cell.textLabel.text = content_[indexPath.section][indexPath.row];
switch (indexPath.section) {
case 0:
cell.accessoryType = (indexPath.row == [PSPDFCache sharedPSPDFCache].strategy) ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
View
6 Examples/PSPDFKitExample/PSPDFShadowView.m
@@ -52,9 +52,9 @@ - (CAGradientLayer *)shadowAsInverse:(BOOL)inverse {
UIColor *darkColor = [UIColor colorWithRed:0.f green:0.f blue:0.f alpha:inverse ? (SHADOW_INVERSE_HEIGHT / SHADOW_HEIGHT) * 0.5f : 0.5f];
if (inverse) {
- newShadow.colors = [NSArray arrayWithObjects:(__bridge id)lightColor.CGColor, (__bridge id)darkColor.CGColor, nil];
+ newShadow.colors = @[(__bridge id)lightColor.CGColor, (__bridge id)darkColor.CGColor];
}else {
- newShadow.colors = [NSArray arrayWithObjects:(__bridge id)darkColor.CGColor, (__bridge id)lightColor.CGColor, nil];
+ newShadow.colors = @[(__bridge id)darkColor.CGColor, (__bridge id)lightColor.CGColor];
}
return newShadow;
}
@@ -68,7 +68,7 @@ - (void)layoutSubviews {
originShadow_ = [self shadowAsInverse:NO];
[self.layer insertSublayer:originShadow_ atIndex:9999];
}
- else if (![[self.layer.sublayers objectAtIndex:0] isEqual:originShadow_]) {
+ else if (![(self.layer.sublayers)[0] isEqual:originShadow_]) {
[self.layer insertSublayer:originShadow_ atIndex:9999];
}
View
16 Examples/PSPDFKitExample/PSPDFStoreManager.m
@@ -114,7 +114,7 @@ - (NSMutableArray *)searchForMagazineFolders {
}
NSMutableArray *foldersCopy = [folders mutableCopy];
- PSPDFMagazineFolder *firstFolder = [foldersCopy objectAtIndex:0];
+ PSPDFMagazineFolder *firstFolder = foldersCopy[0];
[foldersCopy removeObject:firstFolder];
NSMutableArray *magazineArray = [firstFolder.magazines mutableCopy];
@@ -152,7 +152,7 @@ - (PSPDFMagazine *)magazineForUid:(NSString *)uid {
- (PSPDFMagazine *)magazineForFileName:(NSString *)fileName {
for (PSPDFMagazineFolder *folder in self.magazineFolders) {
for (PSPDFMagazine *magazine in folder.magazines) {
- if ([magazine.files count] && [[magazine.files objectAtIndex:0] isEqualToString:fileName]) {
+ if ([magazine.files count] && [(magazine.files)[0] isEqualToString:fileName]) {
return magazine;
}
}
@@ -171,9 +171,9 @@ - (void)loadMagazinesAvailableFromWeb {
PSELog(@"Error while parsing magazine JSON - Dictionary expected. Got this instead: %@", dlMagazine);
}else {
// create and fill PSPDFMagazine
- NSString *title = [dlMagazine objectForKey:@"name"];
- NSString *urlString = [dlMagazine objectForKey:@"url"];
- NSString *imageURLString = [dlMagazine objectForKey:@"image"];
+ NSString *title = dlMagazine[@"name"];
+ NSString *urlString = dlMagazine[@"url"];
+ NSString *imageURLString = dlMagazine[@"image"];
if ([imageURLString length] == 0) {
// if no image key is set, try same location as the pdf, but with jpg ending.
imageURLString = [urlString stringByReplacingOccurrencesOfString:@".pdf" withString:@".jpg" options:NSCaseInsensitiveSearch | NSBackwardsSearch range:NSMakeRange(0, [urlString length])];
@@ -259,7 +259,7 @@ + (void)addSkipBackupAttributeToFile:(NSString *)filePath {
/// Returns the legacy storage path, used when the com.apple.MobileBackup file attribute is not available.
+ (NSString *)legacyStoragePath {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
- return [paths objectAtIndex:0];
+ return paths[0];
}
/// Returns YES if system supports com.apple.MobileBackup file attribute, marks files/folders as not iCloud-backupable.
@@ -289,7 +289,7 @@ + (NSString *)storagePath {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if ([self isBackupXAttributeAvailable]) {
- storagePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
+ storagePath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
}else {
storagePath = [self legacyStoragePath];
// mark that we use the legazy storage.
@@ -505,7 +505,7 @@ - (void)updateNewsstandIcon:(PSPDFMagazine *)magazine {
// if magazine doesn't exist anymore, choose the first magazine in the list
if (!magazine && [self.magazineFolders count]) {
- magazine = [[self.magazineFolders objectAtIndex:0] firstMagazine];
+ magazine = [(self.magazineFolders)[0] firstMagazine];
}
}

0 comments on commit 8789b2a

Please sign in to comment.
Something went wrong with that request. Please try again.