Skip to content
Browse files

Add support to reset queue

  • Loading branch information...
1 parent c107351 commit 0a2b623513d5d6ee14fd82d0b0b8f5997517a517 @marcuswestin committed
View
3 WebViewJavascriptBridge/WebViewJavascriptBridge.h
@@ -19,4 +19,7 @@
* of the webview before calling this method (see ExampleAppDelegate.m) */
- (void)sendMessage:(NSString *)message toWebView:(UIWebView *)webView;
+/* Reset startup messaging queue */
+- (void)resetQueue;
+
@end
View
6 WebViewJavascriptBridge/WebViewJavascriptBridge.m
@@ -21,7 +21,7 @@ @implementation WebViewJavascriptBridge
+ (id)javascriptBridgeWithDelegate:(id <WebViewJavascriptBridgeDelegate>)delegate {
WebViewJavascriptBridge* bridge = [[[WebViewJavascriptBridge alloc] init] autorelease];
bridge.delegate = delegate;
- bridge.startupMessageQueue = [[[NSMutableArray alloc] init] autorelease];
+ [bridge resetQueue];
return bridge;
}
@@ -37,6 +37,10 @@ - (void)sendMessage:(NSString *)message toWebView:(UIWebView *)webView {
else { [self _doSendMessage:message toWebView: webView]; }
}
+- (void)resetQueue {
+ self.startupMessageQueue = [[[NSMutableArray alloc] init] autorelease];
+}
+
- (void)_doSendMessage:(NSString *)message toWebView:(UIWebView *)webView {
message = [message stringByReplacingOccurrencesOfString:@"\\n" withString:@"\\\\n"];
message = [message stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"];

0 comments on commit 0a2b623

Please sign in to comment.
Something went wrong with that request. Please try again.