2011-07-27 7 views
7

新しいライオンズサンドボックスの理解にはいくつか問題があります。NSSavePanelとサンドボックス

私は、Powerboxと呼ばれる信頼できるデーモンプロセスが含まれていることを知っています。その仕事は、サンドボックスアプリケーションに代わって開く/保存ダイアログボックスを表示して制御することです。 Code Signing And Application Sandboxing Guide同様

は言う:

Any time an application running inside a sandbox invokes an NSOpenPanel or NSSavePanel dialog, rather than showing the panels directly, AppKit automatically asks the Powerbox to present the dialog. From a developer perspective, there are no code changes required in terms of how these panels are used; this process is fully transparent.

After the user selects a set of files or directories, the Powerbox uses new functionality in the sandbox kernel module to expand the invoking application's sandbox to allow access to the selected files. By the time the application code queries the panel for the returned URLs or filenames, it already has permission to access those files, and can continue to use the files through almost any API it already uses.

[OK]をクリックします。

NSSavePanel *savePanel = [NSSavePanel savePanel]; 
savePanel.delegate = self; 

savePanel.directoryURL = ...; 
savePanel.nameFieldStringValue = ...; 

[savePanel beginSheetModalForWindow:self.window 
        completionHandler:^(NSInteger returnCode) { 
/* the completion handler */ 
}]; 

奇妙なことは、完了ハンドラの前に呼び出されNSOpenSavePanelDelegate方法の、は、ファイルシステム上のファイルへのアクセスを持っていないということです:私はこのコードを使用して、いくつかの実用的なテストをしました。

これは間違いありませんか?

もしそうなら、panel:validateURL:error:のようなデリゲートのメソッドは役に立たなくなります!

アプリとPowerboxとの接続をより詳しく説明できますか?

+1

なぜあなたの 'validateURL:'メソッドはファイルシステムにアクセスする必要がありますか?問題のファイルのURLがデリゲートメソッドに渡されますが、何が必要ですか? –

+0

たとえば、指定されたURLが書き込み可能であるかどうかを分析し、そうでない場合は、「いいえ」を返します。 – Dev

+0

とにかく、 'NSOpenSavePanelDelegate'のメソッドがファイルシステムにアクセスできないことを私に確認できますか?完了ハンドラだけが選択したファイルにアクセスできますか? (私の意見では、公式のドキュメントは不足しています。) – Dev

答えて

8

Appleに連絡した後、私はRob Kenigerが書いたものを確認できます。NSOpenSavePanelDelegateメソッドはサンドボックスアプリケーションのファイルシステムにアクセスできません。

+0

こんにちは、[Technical Support Incident(TSI)](https://developer.apple.com/support/technical/submit/)を開設しました。 – Dev

+0

ああ、そうです。私が最後に使用したのは、彼らの反応があまり役に立たなかったので、それ以降はそれを使ったことはありませんでした。ありがとう!ところで、ストーリーボードでサンドボックスアプリケーションで[NSSavePanel savePanel]を使用する方法があれば教えてください。それを機能させる方法はありません。 – SpaceDog

+0

@Dev TSIへの返信はありましたか?我々は - 私は他の人と同じ - 同じ問題を抱えています。 – Sebastian

関連する問題