forked from marcuswestin/WebViewJavascriptBridge
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructure of WebViewJavascriptBridge, now the bridges delegate does…
…n't lose the delegation of the webview, it gets, well, bridged. Modified naming to be more conventional
- Loading branch information
1 parent
4dbb54e
commit 83448f4
Showing
4 changed files
with
182 additions
and
125 deletions.
There are no files selected for viewing
28 changes: 16 additions & 12 deletions
28
WebViewJavascriptBridge/Classes/WebViewJavascriptBridge.h
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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,29 +1,33 @@ | |||
#import <Foundation/Foundation.h> | #import <UIKit/UIKit.h> | ||
|
|
||
@protocol WebViewJavascriptBridgeDelegate <NSObject> | @class WebViewJavascriptBridge; | ||
|
|
||
- (void) handleMessage:(NSString*) message fromWebView: (UIWebView *)theWebView; | @protocol WebViewJavascriptBridgeDelegate <UIWebViewDelegate> | ||
|
|||
- (void)javascriptBridge:(WebViewJavascriptBridge *)bridge receivedMessage:(NSString *)message fromWebView:(UIWebView *)webView; | |||
|
|
||
@end | @end | ||
|
|
||
@interface WebViewJavascriptBridge : NSObject <UIWebViewDelegate> { | @interface WebViewJavascriptBridge : NSObject <UIWebViewDelegate> | ||
id <WebViewJavascriptBridgeDelegate> _delegate; | |||
NSMutableArray *_startupMessageQueue; | |||
} | |||
|
|
||
/** Delegate to receive messages from javascript. */ | /** Delegate to receive messages from javascript. */ | ||
@property (readwrite, assign) id <WebViewJavascriptBridgeDelegate> delegate; | /** Defined as IBOutlet for Interface Builder assignment */ | ||
@property (nonatomic, assign) IBOutlet id <WebViewJavascriptBridgeDelegate> delegate; | |||
|
|||
/** Init with a predefined delegate */ | |||
- (id)initWithDelegate:(id <WebViewJavascriptBridgeDelegate>)delegate; | |||
|
|
||
/** Creates & returns new autoreleased javascript Bridge with no delegate set. */ | /** Convenience methods for obtaining a bridge */ | ||
+ (id) javascriptBridge; | + (id)javascriptBridge; | ||
+ (id)javascriptBridgeWithDelegate:(id <WebViewJavascriptBridgeDelegate>)delegate; | |||
|
|
||
/** Sends message to given webView. You need to integrate javascript bridge into | /** Sends message to given webView. You need to integrate javascript bridge into | ||
* this view before by calling WebViewJavascriptBridge#webViewDidFinishLoad: with that view. | * this view before by calling WebViewJavascriptBridge#webViewDidFinishLoad: with that view. | ||
* | * | ||
* You can call this method before calling webViewDidFinishLoad: , than all messages | * You can call this method before calling webViewDidFinishLoad: , then all messages | ||
* will be accumulated in _startupMessageQueue & sended to webView, provided by first | * will be accumulated in _startupMessageQueue & sended to webView, provided by first | ||
* webViewDidFinishLoad: call. | * webViewDidFinishLoad: call. | ||
*/ | */ | ||
- (void) sendMessage:(NSString*) message toWebView:(UIWebView *) theWebView; | - (void)sendMessage:(NSString *)message toWebView:(UIWebView *)webView; | ||
|
|
||
@end | @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
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
Oops, something went wrong.