Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

JS bridge for accessing NSUserDefaults from a UIWebView

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 Demo
Octocat-spinner-32 Externals
Octocat-spinner-32 Source
Octocat-spinner-32 .gitmodules
Octocat-spinner-32 README.md
README.md

JSUserDefaults

Real simple drop-in replacement for UIWebView. Just change the class membership of the web view in your nib (or create it programmatically, that oughta work too) and it'll let you access NSUserDefaults through the JSUserDefaults object. Like this:

[[NSUserDefaults standardUserDefaults] setObject:@"Bar"
                                          forKey:@"Foo"];

(...some time later...)

<script type="text/javascript">
  document.write(JSUserDefaults.objectForKey("Foo"));
</script>

You can also set objects. Any plist object should work fine—arrays, dictionaries, strings, numbers. Other things might be dicey.

See the Demo project for an example.

Something went wrong with that request. Please try again.