Skip to content

Commit 8db942b

Browse files
Merge branch 'jgrantr-jgrantr-UIViewControllerDismiss'
2 parents 75ba3bc + e5de1af commit 8db942b

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

Categories/UIKit/UIViewController+AnyPromise.m

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ + (instancetype)delegateWithPromise:(AnyPromise **)promise;
1313

1414
@implementation UIViewController (PromiseKit)
1515

16-
- (AnyPromise *)promiseViewController:(UIViewController *)vc animated:(BOOL)animated completion:(void (^)(void))block
17-
{
18-
id vc2present = vc;
16+
- (AnyPromise *)promiseViewController:(UIViewController *)vc animated:(BOOL)animated completion:(void (^)(void))block {
17+
__kindof UIViewController *vc2present = vc;
1918
AnyPromise *promise = nil;
2019

2120
if ([vc isKindOfClass:NSClassFromString(@"MFMailComposeViewController")]) {
@@ -72,8 +71,7 @@ - (AnyPromise *)promiseViewController:(UIViewController *)vc animated:(BOOL)anim
7271
[self presentViewController:vc2present animated:animated completion:block];
7372

7473
promise.finally(^{
75-
//TODO can we be more specific?
76-
[self dismissViewControllerAnimated:animated completion:nil];
74+
[vc2present.presentingViewController dismissViewControllerAnimated:animated completion:nil];
7775
});
7876

7977
return promise;

Categories/UIKit/UIViewController+Promise.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extension UIViewController {
3535
if p.pending {
3636
presentViewController(vc, animated: animated, completion: completion)
3737
p.always {
38-
self.dismissViewControllerAnimated(animated, completion: nil)
38+
vc.presentingViewController!.dismissViewControllerAnimated(animated, completion: nil)
3939
}
4040
}
4141

@@ -48,7 +48,7 @@ extension UIViewController {
4848
if p.pending {
4949
presentViewController(nc, animated: animated, completion: completion)
5050
p.always {
51-
self.dismissViewControllerAnimated(animated, completion: nil)
51+
vc.presentingViewController!.dismissViewControllerAnimated(animated, completion: nil)
5252
}
5353
}
5454
return p
@@ -71,7 +71,7 @@ extension UIViewController {
7171
}
7272
throw Error.NoImageFound
7373
}.always {
74-
self.dismissViewControllerAnimated(animated, completion: nil)
74+
vc.presentingViewController!.dismissViewControllerAnimated(animated, completion: nil)
7575
}
7676
}
7777

@@ -80,7 +80,7 @@ extension UIViewController {
8080
vc.delegate = proxy
8181
presentViewController(vc, animated: animated, completion: completion)
8282
return proxy.promise.always {
83-
self.dismissViewControllerAnimated(animated, completion: nil)
83+
vc.presentingViewController!.dismissViewControllerAnimated(animated, completion: nil)
8484
}
8585
}
8686
}

PromiseKit.xcodeproj/project.pbxproj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
431B66E41CAC8022006CFC50 /* Bolts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6373805B1B3E1C8E0060B7CA /* Bolts.framework */; };
1011
43EF78B41C5AB88600BCD8FB /* after.m in Sources */ = {isa = PBXBuildFile; fileRef = 63A60E1F1AFD795B00C4E692 /* after.m */; };
1112
43EF78B51C5AB88600BCD8FB /* after.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63075EBD1AD0EDB3002C46A0 /* after.swift */; };
1213
43EF78B61C5AB88600BCD8FB /* AnyPromise.m in Sources */ = {isa = PBXBuildFile; fileRef = 63A157711ABB59D00002A421 /* AnyPromise.m */; };
@@ -256,7 +257,6 @@
256257
63CD9A5C1BB102EE008D916F /* PromiseKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 63A157701ABB59490002A421 /* PromiseKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
257258
63CD9A5D1BB102EE008D916F /* Umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 63F803A81AB87A8200E4DEE1 /* Umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; };
258259
63CD9A5E1BB102EE008D916F /* AnyPromise+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 63314AE01AEDDD0B0071B6F5 /* AnyPromise+Private.h */; settings = {ATTRIBUTES = (Private, ); }; };
259-
63D1BAA41B256E1A00435BF3 /* Bolts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63D1BAA31B256E1A00435BF3 /* Bolts.framework */; };
260260
63D953C91AEDA3B1004981FF /* AnyPromise.h in Headers */ = {isa = PBXBuildFile; fileRef = 63D953C71AEDA3B1004981FF /* AnyPromise.h */; settings = {ATTRIBUTES = (Public, ); }; };
261261
63D953CA1AEDA4D0004981FF /* AnyPromise.h in Headers */ = {isa = PBXBuildFile; fileRef = 63D953C71AEDA3B1004981FF /* AnyPromise.h */; settings = {ATTRIBUTES = (Public, ); }; };
262262
63DEC34F1B41BD25002F0FB4 /* PMKManifold.test.m in Sources */ = {isa = PBXBuildFile; fileRef = 63DEC34D1B41BCE3002F0FB4 /* PMKManifold.test.m */; };
@@ -498,7 +498,6 @@
498498
63CA14C61AEA9E7400223904 /* OHHTTPStubs.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OHHTTPStubs.framework; path = Carthage/Build/iOS/OHHTTPStubs.framework; sourceTree = "<group>"; };
499499
63CA14C71AEA9E7400223904 /* OMGHTTPURLRQ.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OMGHTTPURLRQ.framework; path = Carthage/Build/iOS/OMGHTTPURLRQ.framework; sourceTree = "<group>"; };
500500
63CD9A621BB102EE008D916F /* PromiseKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PromiseKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
501-
63D1BAA31B256E1A00435BF3 /* Bolts.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Bolts.framework; path = Carthage/Build/iOS/Bolts.framework; sourceTree = "<group>"; };
502501
63D73BE11B20B48F00843146 /* afterlife.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = afterlife.swift; sourceTree = "<group>"; };
503502
63D953C71AEDA3B1004981FF /* AnyPromise.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AnyPromise.h; path = Sources/AnyPromise.h; sourceTree = "<group>"; };
504503
63DEC34D1B41BCE3002F0FB4 /* PMKManifold.test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PMKManifold.test.m; path = CorePromise/PMKManifold.test.m; sourceTree = "<group>"; };
@@ -571,7 +570,7 @@
571570
isa = PBXFrameworksBuildPhase;
572571
buildActionMask = 2147483647;
573572
files = (
574-
63D1BAA41B256E1A00435BF3 /* Bolts.framework in Frameworks */,
573+
431B66E41CAC8022006CFC50 /* Bolts.framework in Frameworks */,
575574
638E0F2E1AEF1A0A0052E28F /* OHHTTPStubs.framework in Frameworks */,
576575
638E0F2F1AEF1A0A0052E28F /* OMGHTTPURLRQ.framework in Frameworks */,
577576
638E0EDB1AEF16530052E28F /* PromiseKit.framework in Frameworks */,
@@ -1919,7 +1918,7 @@
19191918
"$(inherited)",
19201919
);
19211920
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
1922-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
1921+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(PROJECT_DIR)/Carthage/Build/iOS";
19231922
PRODUCT_BUNDLE_IDENTIFIER = "org.promisekit.$(PRODUCT_NAME:rfc1034identifier)";
19241923
PRODUCT_NAME = "$(TARGET_NAME)";
19251924
SWIFT_OBJC_BRIDGING_HEADER = Tests/Categories/bridge.h;
@@ -1938,7 +1937,7 @@
19381937
);
19391938
GCC_NO_COMMON_BLOCKS = YES;
19401939
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
1941-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
1940+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(PROJECT_DIR)/Carthage/Build/iOS";
19421941
PRODUCT_BUNDLE_IDENTIFIER = "org.promisekit.$(PRODUCT_NAME:rfc1034identifier)";
19431942
PRODUCT_NAME = "$(TARGET_NAME)";
19441943
SWIFT_OBJC_BRIDGING_HEADER = Tests/Categories/bridge.h;

0 commit comments

Comments
 (0)