Skip to content

A Extended Class for URL loading . Save into iOS App sandbox from JavaScript interface.

License

Notifications You must be signed in to change notification settings

synapsesoft/UIWebView-NativeStorage

Repository files navigation

UIWebView-NativeStorage

A Extended Class for URL loading . Save into iOS App sandbox from JavaScript interface.

// RootViewController.m
- (void)viewDidLoad
{
  [super viewDidLoad];
  
  UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.frame];
  NSURL *url = [[NSBundle mainBundle] URLForResource:@"index.html" withExtension:nil subdirectory:@"www"];
  [webView loadRequest:[NSURLRequest requestWithURL:url]];
  
  [UIWNativeStorage enable];
  
  [self.view addSubview:webView];
}

- (void)dealloc
{
  [UIWNativeStorage disable];
}
// jQuery
function set(key, value){
  $.get("uiw://nativestorage/setItem", {key: key, value: value})
    .success(function(){
      alert("OK");
    });
}

function get(key){
  $.get("uiw://nativestorage/getItem", {key: key})
    .success(function(response){
      alert(response)
    });
}

About

A Extended Class for URL loading . Save into iOS App sandbox from JavaScript interface.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published