nsdocument

Document Type Icon not showing on custom file MacOS

自古美人都是妖i 提交于 2021-02-08 20:54:12
问题 My application needs to have custom document support, but I did not start out with a Document-template in xcode. I did manage to properly load and save the data by following among other things this tutorial: https://www.brandpending.com/2016/02/21/opening-and-saving-custom-document-types-from-a-swift-cocoa-application/. One problem though, is that my custom icon is not showing on my file! it is still a blank page-icon :(. What Am I doing wrong? Here is my setup: my HSDocument code: -(BOOL

Document-Based App autosave with storyboards

喜欢而已 提交于 2021-01-21 10:29:33
问题 In Document-Based Apps, using XIB files, when a new window is created its behaviour is: Be positioned and sized based on the position of the last active window. If the last active window is still visible then the new window should be cascaded so it doesn't directly overlap. However when using a storyboard this isn't done. See test project. 回答1: You can set shouldCascadeWindows on the window controller in your storyboard: select the window controller in the storyboard select the identity

NSDocument: The document could not be autosaved. The file has been changed by another application

时光总嘲笑我的痴心妄想 提交于 2020-02-03 05:04:42
问题 A search on the title of this post reveals that it's pretty common; indeed, I've gotten this error from Xcode. But I can't seem to find any fixes. I'm seeing it now when I run my program, and it appears to occur during or after changeCountTokenForSaveOperation is called. It seems related to the undo manager, rather than to the fact that i'm using core data, but I may be wrong. Does anyone know what causes this or how to fix it? 回答1: This error can occur with NSPersistentDocument when you

How can I set the title of non-main-windows in an NSDocument application?

你。 提交于 2020-02-02 11:09:12
问题 I am working on a document-based OSX application, with master-detail style windows. I understand how to open additional windows, to display additional information, by using -makeWindowControllers and adding extra window controllers, but I can't set the title of the new windows. I have tried using -setTitle and -windowTitleForDocumentDisplayName in both Document.m and in my sub-classed window controller class, but I can't get the window title to change. How do I change the title of non-main

How to access items in the main nib from a document nib?

允我心安 提交于 2020-01-17 03:46:10
问题 I'm making an NSDocument-based application in which I have an inspector window. This inspector window is part of Pwnshop.nib which is my main nib. I have another nib called 'Document.nib,' which is the document window. I want to be able to change the inspector based on which document window is the active one, sorta like Interface Builder's inspector. The problem is that I want to access an object in another nib . Note that there are multiple document windows, but only one inspector window.

Xcode document icon not updating

那年仲夏 提交于 2020-01-14 01:35:40
问题 I've created an .icns and set it in the Document Types section of my project, but my documents' icons in Finder remain generic. I've noticed that if I change my document type's file extension, the icon displays. Is there a cache I need to clear or some other way to update the icon without changing the file extension? 回答1: To force refresh icon put this into your terminal /System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r

How can I create a document-based application that cannot create a new document?

China☆狼群 提交于 2020-01-13 19:11:50
问题 I have a document-based application that is designed to process existing documents, not to create new documents. How do I prevent the application from creating a new, blank document when launched by opening it from the Finder? 回答1: There is an NSApplication delegate protocol method you can implement. - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender { return NO; } Here's the documentation 回答2: Depending on what you are specifically doing, you might want to override newDocument

How can I create a document-based application that cannot create a new document?

梦想与她 提交于 2020-01-13 19:11:09
问题 I have a document-based application that is designed to process existing documents, not to create new documents. How do I prevent the application from creating a new, blank document when launched by opening it from the Finder? 回答1: There is an NSApplication delegate protocol method you can implement. - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender { return NO; } Here's the documentation 回答2: Depending on what you are specifically doing, you might want to override newDocument

Saving image to Documents directory and retrieving for email attachment

血红的双手。 提交于 2019-12-27 16:48:45
问题 I having trouble figuring out NSBundle & DocumentDirectory data, I have a Camera Picture " imageView " that I'm saving to the NSDocumentDirectoy and then want to retrieve it for attaching to an email, Here the saving code: - (IBAction)saveImage { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"savedImage.png"]

NSDocument isLocked implementation for 10.7?

自古美人都是妖i 提交于 2019-12-25 18:14:12
问题 How can I check if a document isLocked in 10.7? NSDocument has a method isLocked, but it available only on 10.8. 回答1: Here is my implementation: + (BOOL)isDocumentLocked:(NSDocument*)doc { if (doc == nil) { return NO; } else if ([doc respondsToSelector:@selector(isLocked)]) // 10.8 { return [doc isLocked]; } else // OS X version < 10.8 { NSError * error; BOOL isAutosavingSafe = [doc checkAutosavingSafetyAndReturnError:&error]; if (!isAutosavingSafe) { return YES; } if (doc.fileURL == nil)