Re: How to enable local storage in WebView using Swift
Re: How to enable local storage in WebView using Swift
- Subject: Re: How to enable local storage in WebView using Swift
- From: Roland King <email@hidden>
- Date: Wed, 03 Jun 2015 22:42:45 +0800
> On 3 Jun 2015, at 22:23, Juanjo Conti <email@hidden> wrote:
>
> Hi, I'm using WebView and I'd like to enable HTML5 local storage.
>
> I've read some questions on Stack Overflow where the suggestion is to do:
>
> WebPreferences *prefs = [webView preferences];
> [prefs _setLocalStorageDatabasePath:@"~/Library/Application
> Support/MyApp"];
> [prefs setLocalStorageEnabled:YES];
>
> but if I try something similar in Swift:
>
> webView.preferences._setLocalStorageDatabasePath(LocalStoragePath)
> webView.preferences.localStorage = true
> I get a "WebPreferences does not have a member named ..." error.
>
> How can I do it?
>
> Thanks in advance,
_setLocalStorageDatabasePath just has to be a private method and I don’t see any documentation on localStorageEnabled or anything similar so I’m guessing that’s a private method too.
Swift doesn’t let you call private methods, so you can’t do it. Well you could write a little shim in objective c and call that from Swift, I guess even that workaround will fail one day.
A quick google seems to indicate that not only are those methods private, they don’t exist in recent OS, so you need to find another way.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden