• 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: -awakeFromNib, application releasing...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -awakeFromNib, application releasing...


  • Subject: Re: -awakeFromNib, application releasing...
  • From: Jeff Harrell <email@hidden>
  • Date: Wed, 2 Jul 2003 07:52:32 -0500

I have never worried about memory management of objects instantiated in a nib. Maybe that's a gross oversight on my part, but I've just always assumed that objects allocated in the main nib stick around for the life of the program, and that objects in other nibs stay around as long as the nib's owner does.

(When you wrote Foo, did you implement NSCoding?)

On Wednesday, July 2, 2003, at 09:37 AM, Jeremy Faller wrote:

All:


Hello all. I have encountered something in Cocoa, that I can't explain, and would like to know why I'm so silly.

Starting from a New Cocoa Application (non-doc based).

Let's pretend I create an Obj-C class Foo, and write the -init, -release, and and -awakeFromNib methods to just NSLog(@"...."). Additionally, I am going to load Foo.h into my MainMenu.nib file, and instantiate a Foo there.

When the application runs, it just prints the following:

2003-07-02 07:32:31.895 Test[4585] In init!
2003-07-02 07:32:31.901 Test[4585] In awake!
2003-07-02 07:32:31.902 Test[4585] In release!
2003-07-02 07:32:32.005 Test[4585] In release!

If I eliminate the -awakeFromNib method, the -release is never called, and my Foo object sticks around. What's going on, and why is -release getting called twice? (I have tried this on 2 machines running 10.2.6, and get the same results on both.)


Jeremy Faller
email@hidden
_______________________________________________
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.



--
email@hidden
http://homepage.mac.com/jharrell
_______________________________________________
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.

References: 
 >-awakeFromNib, application releasing... (From: Jeremy Faller <email@hidden>)

  • Prev by Date: -awakeFromNib, application releasing...
  • Next by Date: Re: Strong language about Cocoa and Qt.
  • Previous by thread: -awakeFromNib, application releasing...
  • Next by thread: Re: -awakeFromNib, application releasing...
  • Index(es):
    • Date
    • Thread