-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
category on UIViewController #2
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// UIViewController+BAPromise.h | ||
// BAPromise | ||
// | ||
// Created by Ben Allison on 4/21/16. | ||
// Copyright © 2016 Ben Allison. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface UIViewController (BAPromise) | ||
|
||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// UIViewController+BAPromise.m | ||
// BAPromise | ||
// | ||
// Created by Ben Allison on 4/21/16. | ||
// Copyright © 2016 Ben Allison. All rights reserved. | ||
// | ||
|
||
#import "UIViewController+BAPromise.h" | ||
#import "BAPromiseClient.h" | ||
|
||
@implementation UIViewController (BAPromise) | ||
|
||
-(BAPromise *)promise_DismissViewControllerAnimated:(BOOL)animated | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick here but you are using snake_case for first part of ...present... below :-) |
||
{ | ||
BAPromiseClient *promise = BAPromiseClient.new; | ||
if (!self.presentedViewController) { | ||
// TODO(benski) a better error | ||
return [promise rejectedPromise:[NSError errorWithDomain:@"org.benski.promise" code:0 info:nil]]; | ||
} | ||
|
||
[self dismissViewControllerAnimated:animated completion:^{ | ||
[promise fulfil]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this a typo? Now i'm forgetting how to spell it |
||
}]; | ||
return promise; | ||
} | ||
|
||
-(BAPromise *)promise_presentViewController:(UIViewController *)controller | ||
animated:(BOOL)animated | ||
{ | ||
BAPromiseClient *promise = BAPromiseClient.new; | ||
[self presentViewController:controller animated:YES completion:^{ | ||
[promise fullfil]; | ||
}]; | ||
return promise; | ||
} | ||
|
||
- (BAPromise<NSNumber *> *)transitionFromViewController:(UIViewController *)fromViewController toViewController:(UIViewController *)toViewController duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options animations:(void (^ __nullable)(void))animations completion:(void (^ __nullable)(BOOL finished))completion | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would recommend line breaks on fields for this one :-) |
||
{ | ||
BAPromiseClient *promise = BAPromiseClient.new; | ||
[self transitionFromViewController:fromViewController | ||
toViewController:toViewController | ||
duration:duration | ||
options:options | ||
animations:animations | ||
completion:^(BOOL finished) { | ||
[promise fulfillWithObject:@(finished)]; | ||
}]; | ||
return promise; | ||
} | ||
|
||
@end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YES
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hah!
oh it would help if i added the methods to the interface file