use typeof instead of __typeof__

This commit is contained in:
Sami Samhuri 2015-05-09 16:07:17 -07:00
parent 14ff7b46f9
commit 72966ed00f
3 changed files with 22 additions and 22 deletions

View file

@ -289,9 +289,9 @@ static NSString *const StateRestorationModifiedPostKey = @"modifiedPost";
[items replaceObjectAtIndex:[items indexOfObject:saveItem] withObject:indicatorItem]; [items replaceObjectAtIndex:[items indexOfObject:saveItem] withObject:indicatorItem];
[self.toolbar setItems:items animated:NO]; [self.toolbar setItems:items animated:NO];
__weak __typeof__(self) welf = self;
return savePromise.then(^{ return savePromise.then(^{
__typeof__(self) self = welf; __weak typeof(self) welf = self;
typeof(self) self = welf;
NSLog(@"%@ post at path %@", verb, path); NSLog(@"%@ post at path %@", verb, path);
// update our post because "new" may have changed, which is essential to correct operation // update our post because "new" may have changed, which is essential to correct operation
@ -301,7 +301,7 @@ static NSString *const StateRestorationModifiedPostKey = @"modifiedPost";
NSLog(@"Failed to %@ post at path %@: %@ %@", verb, path, error.localizedDescription, error.userInfo); NSLog(@"Failed to %@ post at path %@: %@ %@", verb, path, error.localizedDescription, error.userInfo);
return error; return error;
}).finally(^{ }).finally(^{
__typeof__(self) self = welf; typeof(self) self = welf;
self.textView.editable = YES; self.textView.editable = YES;
self.savePromise = nil; self.savePromise = nil;
[items replaceObjectAtIndex:[items indexOfObject:indicatorItem] withObject:saveItem]; [items replaceObjectAtIndex:[items indexOfObject:indicatorItem] withObject:saveItem];
@ -327,9 +327,9 @@ static NSString *const StateRestorationModifiedPostKey = @"modifiedPost";
- (IBAction)publishOrUnpublish:(id)sender { - (IBAction)publishOrUnpublish:(id)sender {
// TODO: prevent changes while publishing // TODO: prevent changes while publishing
__weak __typeof__(self) welf = self; __weak typeof(self) welf = self;
[self savePost].then(^{ [self savePost].then(^{
__typeof__(self) self = welf; typeof(self) self = welf;
PMKPromise *promise = nil; PMKPromise *promise = nil;
Post *post = self.modifiedPost; Post *post = self.modifiedPost;
if (post.draft) { if (post.draft) {
@ -364,9 +364,9 @@ static NSString *const StateRestorationModifiedPostKey = @"modifiedPost";
presentationController.sourceView = self.view; presentationController.sourceView = self.view;
presentationController.sourceRect = CGRectMake(CGRectGetWidth(self.view.bounds) / 2, CGRectGetMaxY(self.titleLabel.frame), 1, 1); presentationController.sourceRect = CGRectMake(CGRectGetWidth(self.view.bounds) / 2, CGRectGetMaxY(self.titleLabel.frame), 1, 1);
presentationController.permittedArrowDirections = UIPopoverArrowDirectionUp; presentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;
__weak __typeof__(changeTitleViewController) weakChangeTitleViewController = changeTitleViewController; __weak typeof(changeTitleViewController) weakChangeTitleViewController = changeTitleViewController;
changeTitleViewController.dismissBlock = ^{ changeTitleViewController.dismissBlock = ^{
__typeof__(changeTitleViewController) changeTitleViewController = weakChangeTitleViewController; typeof(changeTitleViewController) changeTitleViewController = weakChangeTitleViewController;
NSString *title = changeTitleViewController.articleTitle; NSString *title = changeTitleViewController.articleTitle;
[self updatePostTitle:title]; [self updatePostTitle:title];
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
@ -393,9 +393,9 @@ static NSString *const StateRestorationModifiedPostKey = @"modifiedPost";
- (void)showAlertWithTitle:(NSString *)title message:(NSString *)message { - (void)showAlertWithTitle:(NSString *)title message:(NSString *)message {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
__weak __typeof__(self) welf = self; __weak typeof(self) welf = self;
[alertController addAction:[UIAlertAction actionWithTitle:@"Dismiss" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [alertController addAction:[UIAlertAction actionWithTitle:@"Dismiss" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
__typeof__(self) self = welf; typeof(self) self = welf;
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
}]]; }]];
[self presentViewController:alertController animated:YES completion:nil]; [self presentViewController:alertController animated:YES completion:nil];

View file

@ -281,17 +281,17 @@ static const NSUInteger SectionPublished = 1;
- (IBAction)publish:(id)sender { - (IBAction)publish:(id)sender {
// TODO: activity indicator // TODO: activity indicator
__weak __typeof__(self) welf = self; __weak typeof(self) welf = self;
void (^publish)(PMKPromise *) = ^(PMKPromise *promise) { void (^publish)(PMKPromise *) = ^(PMKPromise *promise) {
self.publishButton.enabled = NO; self.publishButton.enabled = NO;
__typeof__(self) self = welf; typeof(self) self = welf;
promise.then(^{ promise.then(^{
[self requestStatusWithoutCaching]; [self requestStatusWithoutCaching];
}).catch(^(NSError *error) { }).catch(^(NSError *error) {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Error" message:error.localizedDescription preferredStyle:UIAlertControllerStyleAlert]; UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Error" message:error.localizedDescription preferredStyle:UIAlertControllerStyleAlert];
__weak __typeof__(self) welf = self; __weak typeof(self) welf = self;
[alertController addAction:[UIAlertAction actionWithTitle:@"Dismiss" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [alertController addAction:[UIAlertAction actionWithTitle:@"Dismiss" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
__typeof__(self) self = welf; typeof(self) self = welf;
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
}]]; }]];
[self presentViewController:alertController animated:YES completion:nil]; [self presentViewController:alertController animated:YES completion:nil];
@ -301,22 +301,22 @@ static const NSUInteger SectionPublished = 1;
}; };
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Publish" message:nil preferredStyle:UIAlertControllerStyleActionSheet]; UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Publish" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
[alertController addAction:[UIAlertAction actionWithTitle:@"samhuri.net" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { [alertController addAction:[UIAlertAction actionWithTitle:@"samhuri.net" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
__typeof__(self) self = welf; typeof(self) self = welf;
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
publish([self.blogController requestPublishToProductionEnvironment]); publish([self.blogController requestPublishToProductionEnvironment]);
}]]; }]];
[alertController addAction:[UIAlertAction actionWithTitle:@"beta.samhuri.net" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [alertController addAction:[UIAlertAction actionWithTitle:@"beta.samhuri.net" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
__typeof__(self) self = welf; typeof(self) self = welf;
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
publish([self.blogController requestPublishToStagingEnvironment]); publish([self.blogController requestPublishToStagingEnvironment]);
}]]; }]];
[alertController addAction:[UIAlertAction actionWithTitle:@"Push to GitHub" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [alertController addAction:[UIAlertAction actionWithTitle:@"Push to GitHub" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
__typeof__(self) self = welf; typeof(self) self = welf;
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
publish([self.blogController requestSync]); publish([self.blogController requestSync]);
}]]; }]];
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { [alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
__typeof__(self) self = welf; typeof(self) self = welf;
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
}]]; }]];
[self presentViewController:alertController animated:YES completion:nil]; [self presentViewController:alertController animated:YES completion:nil];

View file

@ -27,12 +27,12 @@
if (self.initialRequest) { if (self.initialRequest) {
if (self.promise) { if (self.promise) {
__weak __typeof__(self) welf = self; __weak typeof(self) welf = self;
self.promise.then(^{ self.promise.then(^{
__typeof__(self) self = welf; typeof(self) self = welf;
[self.webView loadRequest:self.initialRequest]; [self.webView loadRequest:self.initialRequest];
}).finally(^{ }).finally(^{
__typeof__(self) self = welf; typeof(self) self = welf;
self.promise = nil; self.promise = nil;
}); });
return; return;
@ -57,9 +57,9 @@
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Error" message:error.localizedDescription preferredStyle:UIAlertControllerStyleAlert]; UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Error" message:error.localizedDescription preferredStyle:UIAlertControllerStyleAlert];
__weak __typeof__(self) welf = self; __weak typeof(self) welf = self;
[alertController addAction:[UIAlertAction actionWithTitle:@"Dismiss" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [alertController addAction:[UIAlertAction actionWithTitle:@"Dismiss" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
__typeof__(self) self = welf; typeof(self) self = welf;
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
}]]; }]];
[self presentViewController:alertController animated:YES completion:nil]; [self presentViewController:alertController animated:YES completion:nil];