objective c - Web View Not Saving HTML5 Local Storage Settings -
objective c - Web View Not Saving HTML5 Local Storage Settings -
i have web app works fine in safari (it uses local storage , saves settings , restores them).
i created web view in xcode 4.5.2 loads web app. know default web view doesn't back upwards local storage added code enable app doesn't work @ all.
my code in appdelegate.m:
- (void)applicationdidfinishlaunching:(nsnotification *)anotification { webpreferences *prefs = [webview preferences];. [prefs _setlocalstoragedatabasepath:@"~/library/testapp/localstorage"]; nsstring *path = [[nsbundle mainbundle] pathforresource:@"test" oftype:@"html"]; nsurl* fileurl = [nsurl fileurlwithpath:path]; nsurlrequest* request = [nsurlrequest requestwithurl:fileurl]; [self.webview.mainframe loadrequest:request]; } @end
this part added enable local storage:
webpreferences *prefs = [webview preferences];. [prefs _setlocalstoragedatabasepath:@"~/library/testapp/localstorage"];
i next error: "expected expression" - "no known class method selector 'preferences'"
-preferences
instance method on webview
, not class method. you'll want webpreferences *prefs = [self.webview preferences]
retrieve preferences webview
. in add-on calling -[webpreferences _setlocalstoragedatabasepath:]
, believe you'll want phone call -[webpreferences setlocalstorageenabled:]
ensure local storage enabled.
objective-c xcode webview
Comments
Post a Comment