Skip to content

Commit

Permalink
Merge pull request Xcode-Snippets#31 from dsklen/master
Browse files Browse the repository at this point in the history
Small modernizations
  • Loading branch information
mattt committed Nov 15, 2013
2 parents 71e1ef7 + 3fb94d4 commit 39c9abe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
12 changes: 6 additions & 6 deletions frcd.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,24 @@ - (void)controller:(NSFetchedResultsController *)controller
atIndexPath:(NSIndexPath *)indexPath
forChangeType:(NSFetchedResultsChangeType)type
newIndexPath:(NSIndexPath *)newIndexPath
{
{
switch(type) {
case NSFetchedResultsChangeInsert:
[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView insertRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
break;
case NSFetchedResultsChangeDelete:
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
break;
case NSFetchedResultsChangeUpdate:
[self configureCell:[self.tableView cellForRowAtIndexPath:indexPath] forRowAtIndexPath:indexPath];
break;
case NSFetchedResultsChangeMove:
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
break;
}
}

- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
[self.tableView endUpdates];
}
}
2 changes: 1 addition & 1 deletion library.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
// Completion Scope: Function or Method

NSArray *librarySearchPaths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *libraryDirectory = [librarySearchPaths count] == 0 ? nil : [librarySearchPaths objectAtIndex:0];
NSString *libraryDirectory = [librarySearchPaths firstObject];
5 changes: 2 additions & 3 deletions mailcomp.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ - (void)presentModalMailComposerViewController:(BOOL)animated {
[composeViewController setMessageBody:<#Body#> isHTML:YES];
[composeViewController setToRecipients:@[<#Recipients#>]];

[self presentModalViewController:composeViewController animated:animated];
[self presentViewController:composeViewController animated:animated completion:nil];
} else {
[[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil) message:NSLocalizedString(@"<#Cannot Send Mail Message#>", nil) delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", nil) otherButtonTitles:nil] show];
}
Expand All @@ -31,8 +31,7 @@ - (void)mailComposeController:(MFMailComposeViewController *)controller
if (error) {
NSLog(@"%@", error);

<#statements#>
}

[self dismissModalViewControllerAnimated:YES];
[self dismissViewControllerAnimated:YES completion:nil];
}

0 comments on commit 39c9abe

Please sign in to comment.