Created
March 26, 2017 16:28
-
-
Save bolencki13/5784511b0d9b3e69f72388cfe0283b00 to your computer and use it in GitHub Desktop.
WKWebView load request with completion block
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// WKWebview+Complete.h | |
// partyface | |
// | |
// Created by Brian Olencki on 3/26/17. | |
// Copyright © 2017 Brian Olencki. All rights reserved. | |
// | |
#import <WebKit/WebKit.h> | |
@interface WKWebView (Complete) | |
- (WKNavigation *)loadRequest:(NSURLRequest *)request complete:(void(^)())complete; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// WKWebview+Complete.m | |
// partyface | |
// | |
// Created by Brian Olencki on 3/26/17. | |
// Copyright © 2017 Brian Olencki. All rights reserved. | |
// | |
#import "WKWebView+Complete.h" | |
@implementation WKWebView (Complete) | |
- (WKNavigation *)loadRequest:(NSURLRequest *)request complete:(void (^)())complete { | |
WKNavigation *navigation = [self loadRequest:request]; | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){ | |
while (self.isLoading) { | |
[NSThread sleepForTimeInterval:0]; | |
} | |
dispatch_async(dispatch_get_main_queue(), ^(void){ | |
complete(); | |
}); | |
}); | |
return navigation; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment