Converting a basic Cocoa application to a document-based application -


my team , have been working on existing, non-document-based cocoa application. our first cocoa app, although we've done number of ios apps far.

the app should document-based, though, i've begun trying convert it. things here & there don't seem working. example, file -> open menu item permanently disabled (although got file -> save menu item enabled; wouldn't). in addition, can click red x close window, although file -> close menu item disabled; however, when close window via x button, dealloc method in nsdocument implementation (spdocumentinfo) not invoked. created sample, brand-new document-based app comparisons; when close window there, spdocument implementation's dealloc method indeed invoked (as i'd expect.) concerns me.

i made lot of changed project here , there; include:

  • made spdocumentinfo extend spdocument in .h file:

    @interface spdocumentinfo : nsdocument <nswindowdelegate> 
  • implemented following in spdocumentinfo:

    - (nsstring *)windownibname {     return @"spdocument"; }  - (void)windowcontrollerdidloadnib:(nswindowcontroller *) acontroller {     [super windowcontrollerdidloadnib:acontroller]; }  - (nsdata *)dataoftype:(nsstring *)typename error:(nserror **)outerror {     nsstring *xml = [self toxml];     return [xml datausingencoding:nsutf8stringencoding]; }  - (bool)readfromdata:(nsdata *)data oftype:(nsstring *)typename error:(nserror **)outerror {     // make work later     if ( outerror != null ) {         *outerror = [nserror errorwithdomain:nsosstatuserrordomain code:unimperr userinfo:null];     }     return yes; } 
  • edited .plist file add "document types". among other things, defined "cocoa nsdocument class" = "spdocumentinfo".

  • altered connections in spdocumentinfo match connections in sample document-based app. example, in spdocument.nib, file's owner (which represents spdocumentinfo) window's delegate.

so, i'm wondering if there other sorts of things might missing in converting doc-based app. or, there guides on how this? (i've looked couldn't find any). or should start on new document-based app , try retrofit of our stuff it? in general, have experience this?

this more of opinion direct answer, if you're new mac side , document-based applications, path of least resistance create new doc-based xcode project template , move relevant code over, plugging template places needed.


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -