GetFolderItem Sandboxed

Hi everybody,

How can I open a FolderItem in a sandboxed App WITHOUT using the OpenDialog?

f = GetFolderItem(path, FolderItem.PathTypeNative) opens the FolderItem
but
t = TextInputStream.Open(f) failes.

Debugger:
f.Exists is True
f.isReadable is False
f.isWritable is False
f.LastErrorCode is 1

Is using the OpenDialog the only way to get access to the Files data?
Thanks for any help

The first time, you have to use a OpenDialog (or SaveDialog), unless the file is within your application container.

Once you have access to the file, you can store it either by using NSDocumentController (the code is here in the forums) or via a Security-Scoped bookmark. Again the code is on this very forum. I would suggest you spend some time and read the previous discussions regarding the two very different functions and their usage.

It may be a bit heavier than you’d like right at this moment, but by understanding it now, will save you a tremendous amount of trouble in the future.

Thank’s Sam,

I have installed a recent File Menu using NSDocumentController (actually your example SDR_RecentItems)
and that works fine.
And I was reading everthing I could find about Sandboxing (Forum, Google) but just hoped that I was
missing something and there is a way to open files without OpenDialog.

Part of my app design is to store FileNames in a DB, present them in a Listbox, if the user doubleclicks a FileName
I retrive the path with SpotlightQuery and open the File.

Looks like I have to redesign that part of my application.

(Not to semi-hijack the conversation) Is sandboxing only important if you want to sell through MAS? And same question asked a different way, does MAS require apps be sandboxed?

And, while I’m asking, does MAS require Cocoa now? If so, what if you supply a REAL/Xojo Cocoa app but include a dylib in the bundle that doesn’t use any Cocoa.framework calls?

[quote=114533:@Garth Hjelte]does MAS require apps be sandboxed?

And, while I’m asking, does MAS require Cocoa now? [/quote]

Yes, apps in the MAS must be sandboxed
No, as far as I know, you can still put Carbon apps there. It may change at any time.

You’re welcome.

[quote=114481:@Hanspeter Stocker]I have installed a recent File Menu using NSDocumentController (actually your example SDR_RecentItems)
and that works fine.[/quote]
Awesome :slight_smile:

I would advise if you can, re-think how this might work. Without knowing what you intend to do exactly, you can still launch the file (with the default application) even if you don’t have access to read or write it. You can also get the finder to reveal it.

You should absolutely target the App Store, if you want maximum exposure for your application. However in saying that, App Wrapper doesn’t work when Sandboxed, so it’s not in the App Store. Some apps can still be a success outside of the store.

As for Carbon - my advice is to steer clear of it. There are Sandboxing issues that haven’t been fixed with Carbon, also we don’t know when Apple will decide that Carbon is officially deprecated and block apps using Carbon. However we do know it’s coming!