プログラム内でwebviewのlocalstorageを使用していますが、次のプログラムの実行開始時に常に消されます。私はファイルをチェックし、プログラムが実行された後も持続しますが、次の開始時にはそれを拭き取ります。任意の助けをいただければ幸いですどのようにlocalstorageを設定してプログラムの実行中も持続するようにします
- (void)awakeFromNib {
WebPreferences *prefs = [webView preferences];
[prefs _setLocalStorageDatabasePath:@"~/Library/Application Support/MyApp"];
[prefs setDatabasesEnabled:YES];
[prefs setLocalStorageEnabled:YES];
NSString *resourcesPath = [[NSBundle mainBundle] resourcePath];
NSString *htmlPath = [resourcesPath stringByAppendingString:@"/htdocs/index.html"];
[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:htmlPath]]];
[window setDelegate:self];
}
:
は、ここに私のコードです!ありがとう
これはiOS用ではありません。下記の免責事項を読んでください。次の2つのリンクは、まだあなたの役に立つかもしれません:http://stackoverflow.com/questions/2640724 http://stackoverflow.com/questions/4625484/how-to-get-localstorage-to-work-in-a -webview-in-xcode – abelito
投稿する前にこれらの2つを確認しましたが、役に立つ情報は見つかりませんでした。 localstorageは組み込みのWebkitなので可能なはずです。 – NycCompSci
これは10.7とXcode 4.3.3で私にとってうまくいった:http://stackoverflow.com/questions/10609644/localstorage-not-persisting-in-osx-app-xcode-4-3 – endemic