2011-07-27 5 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.

좋아. 이 코드를 사용하여 몇 가지 구체적인 테스트를했다 :

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이 쓰기 가능한지 분석하고 싶습니다. 그렇지 않으면 'NO'를 반환합니다. – 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