nsdocument

How to implement a complex NSDocument-based app that imports and exports non-native file types?

巧了我就是萌 提交于 2019-12-04 13:21:37
I'm working on an app that supports a very complicated set of operations. It's akin to something like Xcode, in that the main document is represented by something like a project window, with numerous entries in it. The document on disk is a bundle (meaning a directory with a file & folder structure underneath). There is at least one file type that it can import and export ( .mfst), but it's not intended to directly edit this file type. That is, opening this file type results in a native document type being created, and the contents of the file being imported into it. The on-disk file is a

Document-based application, or not?

感情迁移 提交于 2019-12-03 17:22:56
I'm writing a desktop app that could be used to manage a dance academy. My Core Data model contains such entities as Student, Teacher, Class, Invoice, etc along with the various relationships between them. My planned UI consists of a vertical split view with an iTunes-like OutlineView on the left hand-side. When you click on the "Students" item in that outline view, the contents of the right-hand panel get swapped in from the ManageStudents NIB. Likewise, if you click on the "Invoices" item in the outline view, the current view will be replaced with the ViewInvoices view. Fairly simple, yes?

How do you bind a storyboard view to a Core Data entity when using NSDocument?

北城以北 提交于 2019-12-03 08:05:57
I'm building an OS X app that uses core data, NSDocument, storyboards, and Cocoa bindings. My expectation is that the following occurs: An instance of MyDocument ( NSDocument subclass) is created. MyDocument creates a Core Data NSManagedObjectContext that represents the document's data. MyDocument instantiates an NSWindowController from the storyboard by its identifier. Within the storyboard, the window controller contains DocumentEditorViewController ( NSViewController subclass) which displays and edits the document. Within the storyboard, DocumentEditorViewController has an NSArrayController

Cocoa/Obj-C - Open file when dragging it to application icon

扶醉桌前 提交于 2019-12-03 01:32:10
Currently there is a button on my app inteface which allow to open a file, here is my open code: In my app.h: - (IBAction)selectFile:(id)sender; In my app.m: @synthesize window; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { } - (IBAction)selectFile:(id)sender { NSOpenPanel *openPanel = [NSOpenPanel openPanel]; NSArray *fileTypes = [NSArray arrayWithObjects:@"xml",nil]; NSInteger result = [openPanel runModalForDirectory:NSHomeDirectory() file:nil types:fileTypes ]; if(result == NSOKButton){ NSString * input = [openPanel filename]; How can I edit my code to allow

NSDocument to hold a complete folder?

落爺英雄遲暮 提交于 2019-12-02 19:41:14
I ask sorry if this argument has already been covered, but after some research i found nothing precise. I need to make a document based application, where the document is actually not a single file but a structured collection of files, in a directory. The windows will show a pdf contained in the folder, with a specific filename, and enrich it with informations from the other files in the folder. I cannot use pdf annotations to achieve this, i really need to keep the files separated from the pdf. What's the best approach to achieve this? All the sample code i found use a single file.. You can

Include iCloud on save dialog box in mac app

偶尔善良 提交于 2019-12-02 01:29:18
I have implemented the iCloud support on my Mac document-based app. NSDocument subclass can handle open e save file on local storage and iCloud . But, I can upload my files on iCloud only dragging it on the Open-New File Panel. When the app prompt the user the location to save the file, iCloud is not on the list. Isn't it supported by default like in TextEdit? I have to implement with my own code? Image here: I managed to fix this problem by recreating certificates and provisioning profiles removing the LSItemContentTypes key for my CFBundleDocumentTypes entry in the Info.plist. I also removed

How can you implement the NSDocument method -canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo: in Swift?

为君一笑 提交于 2019-12-01 21:06:08
问题 In my application, a NSDocument subclass mission-critical hardware – users really don’t want to close a document by accident! So, I’ve implemented canCloseDocumentWithDelegate… to show an NSAlert and ask before closing. I am now trying to implement this same thing in an application written in Swift. Since the answer comes asynchronously, the “should close” result is passed to a callback on a delegate, and not simply returned. In the documentation for -canCloseDocumentWithDelegate

How can you implement the NSDocument method -canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo: in Swift?

半腔热情 提交于 2019-12-01 18:31:13
In my application, a NSDocument subclass mission-critical hardware – users really don’t want to close a document by accident! So, I’ve implemented canCloseDocumentWithDelegate… to show an NSAlert and ask before closing. I am now trying to implement this same thing in an application written in Swift. Since the answer comes asynchronously, the “should close” result is passed to a callback on a delegate, and not simply returned. In the documentation for -canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo: , it says: The shouldCloseSelector callback method should have the following

Adding string on existing txt file -iOS

我怕爱的太早我们不能终老 提交于 2019-12-01 12:11:34
As shown code below, It is outputting several individual .txt files. However, I am looking in a way to save everything into one txt file. How could I append new string at the end of saved txt file? -(void)saveData:(NSString *)data { NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentDirectory=[paths objectAtIndex:0]; NSString *fileName=[NSString stringWithFormat:@"%@/%d.txt",documentDirectory,fileInt]; NSString *content=data; [content writeToFile:fileName atomically:NO encoding:NSStringEncodingConversionAllowLossy error:nil]; NSLog

Adding string on existing txt file -iOS

╄→гoц情女王★ 提交于 2019-12-01 10:52:27
问题 As shown code below, It is outputting several individual .txt files. However, I am looking in a way to save everything into one txt file. How could I append new string at the end of saved txt file? -(void)saveData:(NSString *)data { NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentDirectory=[paths objectAtIndex:0]; NSString *fileName=[NSString stringWithFormat:@"%@/%d.txt",documentDirectory,fileInt]; NSString *content=data;