paanvaannd
paanvaannd

Reputation: 191

Remove save feature in cocoa document-based application

I am currently working on a web browser project from Apple's Mac Dev site.

I have completed the project, but have a bit of a problem. I have created the project as a Document-Based Cocoa Application, and now whenever I enter text in any text field on the web, the red traffic light button shows a black dot in the middle that signifies an unsaved document. When I try to close the window or entirely quit the application, a warning pops up like that in TextEdit or Pages where it alerts me to unsaved changes. It's not too much of a problem, but I would like if someone could please tell me how to remove that feature of a Cocoa Document-Based Application.

Upvotes: 0

Views: 714

Answers (2)

Devilz
Devilz

Reputation: 11

An easier solution would simply be to override the isDocumentEdited method to always return NO.

- (BOOL)isDocumentEdited {
    return NO;
}

Upvotes: 1

bbum
bbum

Reputation: 162712

Why a document based application if your application isn't document based? Document based applications inherently include the concept of open and save; it is a fundamental part of what they are.

In any case, you could "work around" this by configuring NSDocument appropriately; override the proper methods and otherwise muck with the change count & dirty state of the document. But it'll be just that, a workaround. The documentation for NSDocument has all the information you need.

A cleaner overall solution would be to refactor your app to not use NSDocument. Creating multiple windows is quite straightforward in Cocoa (an action method tied to a menu item where the action method loads a nib file; if I remember correctly, you could even use NSWindowController still).

Upvotes: 2

Related Questions