nssavepanel

Getting path to users Library folder in OS X

。_饼干妹妹 提交于 2019-12-05 03:19:48
I need to open a NSSavePanel with the users Library folder as destination folder. Normally I would do this by entering ~/Library/ in [NSSavePanel beginSheetForDirectory] . This works fine as long as the application is not sandboxed. For sandboxed applications this will result in the NSSavePanel trying to access a folder inside the applications document "box". I cannot refer to /Users/username/Library/ as I do not know the users username at runtime. So how do I link to this path in cocoa? Not sure if this will work on a sandboxed application but this is how I do it right now. This will return

NSSavePanel is not saving a file after sandboxing an app

好久不见. 提交于 2019-12-04 03:54:08
I'm having a problem saving a string file with NSSavePanel after sandboxing the app for the Mac App Store. I set com.apple.security.files.user-selected.read-write to YES and the NSOpenPanel is working as it should. When I try to save a new file, though, it seems that everything is working fine but then there is no saved file where it should be.... This is the code I am using to save the file: NSSavePanel *save = [NSSavePanel savePanel]; long int result = [save runModal]; if (result == NSOKButton) { NSString *selectedFile = [save filename]; NSString *fileName = [[NSString alloc] initWithFormat:

NSSavePanel and the Sandbox

夙愿已清 提交于 2019-12-04 03:21:19
I have some problems understanding the new Lion's Sandbox. I know that Lion includes a trusted daemon process called Powerbox whose job is to present and control open/save dialog boxes on behalf of sandboxed applications. Like the Code Signing And Application Sandboxing Guide says: 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

How can i use NSSavePanel to select a directory?

时间秒杀一切 提交于 2019-12-04 00:11:25
I need the user select an existing or a new directory where my app can save a few files. Can i do this with NSSavePanel or is there another directory selector class? NSSavePanel doesn't give the ability to choose folders but NSOpenPanel (a subclass of NSSavePanel) does. You set YES for -setCanChooseDirectories: and -setCanCreateDirectories:, set a prompt that makes sense with -setPrompt:. 来源: https://stackoverflow.com/questions/3396081/how-can-i-use-nssavepanel-to-select-a-directory

Using Cocoa NSSavePanel in Sandbox causes Assertion failure

痞子三分冷 提交于 2019-12-03 04:43:40
I'm trying to use the NSSavePanel and added this line to my code. let test = NSSavePanel() Everytime this code is called the this error appears. I'm not quite sure what is happening here because I'm only creating a new object. Any help appreciated. Thanks! *** Assertion failure in -[NSVBSavePanel viewWillInvalidate:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1561.20.106/Nav.subproj/OpenAndSavePanelRemote/NSVBOpenAndSavePanels.m:387 2017-12-23 18:11:33.110099+0100 test[27753:1527254] -[NSVBSavePanel init] caught non-fatal NSInternalInconsistencyException 'bridge absent'

Why is NSOpenPanel/NSSavePanel showing memory leak?

僤鯓⒐⒋嵵緔 提交于 2019-11-29 12:13:35
Not sure why, but making a simple [[NSOpenPanel openPanel] runModal]; creates a memory leak - seen in Leaks Instrument. Seems off. It's an auto-released object, shouldn't it be automatically released after ARpool is drained? Is there a way to fix this? NSOpenPanel is a singleton, which means you always get the same instance of the object every time you use it. This means that the first time you call [NSOpenPanel openPanel] , an instance of NSOpenPanel is created and not released. This is not a leak, it's an optimisation. However, sometimes the Leaks instrument picks up such once-only

Saving an NSView to a png file?

本小妞迷上赌 提交于 2019-11-28 22:02:46
I am making a simple program that creates game cards for a game I play. I have sent it out to some friends of mine for testing, but they really want it to save images, not just print them. I have tried to make it save as a .png file. I have to questions here. How can I make it save my view as a .png file, including all of the view's NSImageWells. How can I add an NSPopupButton to an NSSavePanel to allow users to select a format? Any help is greatly appreciated. First create a TIFF representation of your view: // Get the data into a bitmap. [self lockFocus]; rep = [[NSBitmapImageRep alloc]

Why is NSOpenPanel/NSSavePanel showing memory leak?

╄→гoц情女王★ 提交于 2019-11-28 05:42:42
问题 Not sure why, but making a simple [[NSOpenPanel openPanel] runModal]; creates a memory leak - seen in Leaks Instrument. Seems off. It's an auto-released object, shouldn't it be automatically released after ARpool is drained? Is there a way to fix this? 回答1: NSOpenPanel is a singleton, which means you always get the same instance of the object every time you use it. This means that the first time you call [NSOpenPanel openPanel] , an instance of NSOpenPanel is created and not released. This is