nssavepanel

NSSavePanel, CGImageDestinationFinalize and OS X sandbox

霸气de小男生 提交于 2019-12-13 05:25:38
问题 I'm using NSSavePanel to let user select image to save to in my app. Everything worked fine until I enabled app sandboxing and entitlements. The problem occurs with selection of an already existing file. My code is like this: // Create a URL to our file destination and a CGImageDestination to save to. CGImageDestinationRef imageDestination = CGImageDestinationCreateWithURL((CFURLRef)[savePanel URL], (CFStringRef)newUTType, 1, NULL); CGImageDestinationAddImage(imageDestination, cgimage,

NSSavePannel - how to restrict user to only save one one set directory?

空扰寡人 提交于 2019-12-13 03:02:39
问题 User has to save a file, but I only want them saving the file in one folder. How to do this? I have already tried implementing the delegate and forcefully setting back the directory if it is different. This does not work. The user is still able to select other folders when the save panel opens extension Project: NSOpenSavePanelDelegate { func panel(_ sender: Any, didChangeToDirectoryURL url: URL?) { if url != testsFolder { (sender as! NSSavePanel).directoryURL = testsFolder } } func panel(_

NSSavePanel and the Sandbox

可紊 提交于 2019-12-12 08:46: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

Should I call NSSavePanel runModal method only from main thread?

二次信任 提交于 2019-12-12 01:52:12
问题 I have weird, though rare, crashes in my application. I suspect that it happens because runModal of NSSavePanel is called in a thread different from the main thread. Am I correct that it might be the cause for the crashes? 回答1: See the Threading Programming Guide from Apple: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Multithreading/Introduction/Introduction.html "Thread-Unsafe Classes: NSWindow and all of its descendants." NSSavePanel is a descendant of NSWindow.

NSSavePanel crash in sandbox app OS X 10.10

≯℡__Kan透↙ 提交于 2019-12-11 06:30:11
问题 I'm using the NSSavePanel in OS X 10.10 in a sandboxed app to let the user choose the save location of a file (pretty standard), however the app crashes when i call: NSSavePanel *panel = [NSSavePanel savePanel]; I get this in the debugger: 2014-10-14 18:22:16.019 Farm Hand[2807:942766] an error occurred while attempting to connect to listener 'com.apple.view-bridge': Connection interrupted 2014-10-14 18:22:16.020 Farm Hand[2807:942766] *** Assertion failure in +[NSXPCSharedListener

Save/Copy a file from Bundle to Desktop using NSSavePanel

余生长醉 提交于 2019-12-11 03:18:48
问题 I’m creating a macOS app which ships with some .zip files within its Bundle directory. Users should be able to save these files from my app to a custom directory. I found NSSavePanel and thought it is the right approach — that’s what I have so far: @IBAction func buttonSaveFiles(_ sender: Any) { let savePanel = NSSavePanel() let bundleFile = Bundle.main.resourcePath!.appending("/MyCustom.zip") let targetPath = NSHomeDirectory() savePanel.directoryURL = URL(fileURLWithPath: targetPath

NSSavePanel can't change file name

吃可爱长大的小学妹 提交于 2019-12-11 03:05:06
问题 In my mac app I'm using NSSavePanel - but it's behaving very strange. Sometimes I can't change the default name of the file. I'm using it like this: NSSavePanel *savePanel = [NSSavePanel savePanel]; [savePanel setAllowedFileTypes:@[@"jpg"]]; [savePanel setLevel:CGShieldingWindowLevel()]; if([savePanel runModal] == NSFileHandlingPanelOKButton) { //saving file } I can't find why sometimes it lets me change the file name and other times no, I can save a file but a changing name in save panel is

NSSavePanel crashes on Yosemite

核能气质少年 提交于 2019-12-10 17:26:51
问题 I am using NSSavePanel to save image. I have used IKSaveOption which gets added to the NSSavePanel. When save panel tries to open the sheet for window it crashes saying - *** Assertion failure in -[IKSaveOptionsContainer _didChangeHostsAutolayoutEngineTo:], /SourceCache/AppKit/AppKit-1343.14/Layout.subproj/NSView_Layout.m:577 - Should translate autoresizing mask into constraints if _didChangeHostsAutolayoutEngineTo:YES. I am following this code: NSSavePanel *savePanel = [NSSavePanel savePanel

NSSavePanel is not saving a file after sandboxing an app

此生再无相见时 提交于 2019-12-05 20:54:27
问题 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 ==

NSSavePanel: Squelching the “confirm replace?” dialog

倾然丶 夕夏残阳落幕 提交于 2019-12-05 14:52:09
In the Nav Services world one could specify kNavDontConfirmReplacement as an option to create a NavDialogRef that would not ask the user to confirm the replacement of a file when saving with a file name that already exists. How do I specify an equivalent behavior with the Cocoa NSSavePanel ? Here's how it can be done: Add a delegate to handle NSSavePanel callbacks Override - (NSString*)panel:(id)sender userEnteredFilename:(NSString*)filename confirmed:(BOOL)okFlag in your delegate In the delegate: If okFlag is false , return filename Otherwise, retain filename as an NSString* in your delegate