• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: { Semi-Newbie } Inverse of +initialize?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: { Semi-Newbie } Inverse of +initialize?


  • Subject: Re: { Semi-Newbie } Inverse of +initialize?
  • From: "John C. Randolph" <email@hidden>
  • Date: Fri, 11 Oct 2002 16:32:24 -0700

On Friday, October 11, 2002, at 03:55 PM, David Remahl wrote:

Cleaning up temporary files and the like should be done in the app
delegate's -applicationWillTerminate: method.

I don't think that is particularly good OO design...The application delegate
shoudn't have to know what connections of different kinds other objects in
the program may create.

Let me just point out that it's the app delegate that gets the -application:shouldOpenUntitledFile:, - application:openTempFile:, -application:openFile messages and the like.

There is of course the possibility of making some
kind of convention that objects which need to "say goodbye" in one way or
the other respond to a -goodbye message or -cleanup or something like that,
but I think the -dealloc method is a more logical place to place clean up
code.

-dealloc is for freeing memory. If your objects need to know when an app is terminating because they do things like create temp files, they should sign up for the relevant notifications.

-jcr


John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
http://developer.apple.com/cocoa/index.html
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: { Semi-Newbie } Inverse of +initialize?
      • From: Chris Ridd <email@hidden>
References: 
 >Re: { Semi-Newbie } Inverse of +initialize? (From: David Remahl <email@hidden>)

  • Prev by Date: STL vector not working
  • Next by Date: contextual menus in finder / cocoa & carbon integration
  • Previous by thread: Re: { Semi-Newbie } Inverse of +initialize?
  • Next by thread: Re: { Semi-Newbie } Inverse of +initialize?
  • Index(es):
    • Date
    • Thread