2011-07-27 9 views
7

मुझे नए शेर के सैंडबॉक्स को समझने में कुछ समस्याएं हैं।एनएसएसवीपैनल और सैंडबॉक्स

मुझे पता है कि शेर में Powerbox नामक एक विश्वसनीय डेमॉन प्रक्रिया शामिल है जिसका काम sandboxed अनुप्रयोगों की ओर से खुले/सहेजे गए संवाद बॉक्स को प्रस्तुत और नियंत्रित करना है।

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:' विधि को फ़ाइल सिस्टम तक पहुंच की आवश्यकता क्यों है? प्रश्न में फ़ाइल का यूआरएल प्रतिनिधि विधि को पास कर दिया गया है, आपको और क्या चाहिए? –

+0

मैं विश्लेषण करना चाहता हूं, उदाहरण के लिए, यदि निर्दिष्ट यूआरएल लिखने योग्य है, और यदि नहीं, तो 'NO' वापस करें। – Dev

+0

वैसे भी, आप मेरी पुष्टि कर सकते हैं कि 'NSOpenSavePanelDelegate' के तरीकों में फाइल सिस्टम तक पहुंच नहीं है? केवल पूरा करने वाला हैंडलर चयनित फ़ाइल तक पहुंच सकता है? (आधिकारिक दस्तावेज की मेरी राय में कमी है।) – Dev

उत्तर

8

ऐप्पल से संपर्क करने के बाद, मैं पुष्टि कर सकता हूं कि रॉब केनिगर ने क्या लिखा: NSOpenSavePanelDelegate विधि के पास sandboxed अनुप्रयोगों में फाइल सिस्टम तक पहुंच नहीं है।

+0

हैलो, मैंने एक [तकनीकी सहायता घटना (टीएसआई)] खोला है (https://developer.apple.com/support/technical/submit/)। – Dev

+0

आह, मैं देखता हूं। पिछली बार मैंने उपयोग किया था कि उनकी प्रतिक्रिया इतनी बेकार थी कि मैंने उसके बाद कभी इसका उपयोग नहीं किया। धन्यवाद! वैसे, क्या आपको पता है कि स्टोरीबोर्ड वाले सैंडबॉक्स वाले ऐप्स पर [NSSavePanel savePanel] का उपयोग करने का कोई तरीका है या नहीं? इसे काम करने का कोई तरीका नहीं है। – SpaceDog

+0

@Dev क्या आपको अपने टीएसआई के लिए कोई उपयोगी उत्तर मिला? हम - और मैं दूसरों को मानता हूं - एक ही समस्या है। – Sebastian

संबंधित मुद्दे