• 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: Regarding MVC design pattern
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Regarding MVC design pattern


  • Subject: Re: Regarding MVC design pattern
  • From: Sai <email@hidden>
  • Date: Wed, 19 May 2010 17:17:58 +0800

Hi Jack,

Thank you for your quick response. Your answer is very useful.
Since I have pasted some of my codes in the previous mail. I just
wonder if you have any comments on my codes, anything I can
improve for this little app? Any advice will be very appreciated.

On Wed, May 19, 2010 at 5:07 PM, Jack Nutting <email@hidden> wrote:

> On Wed, May 19, 2010 at 10:48 AM, Sai <email@hidden> wrote:
> > I have two questions:
> > 1. Look at the awakeFromNib method of Controller, my output of the retain
> > count to the console are
> > myModel retain count: 5
> > controller retain count: 17
> > both number are very surprised me, why is that? I suppose they should be
> 2
> > or 1?
> > Can anyone explain please?
>
> When you've just loaded a nib file, there can be all sorts of
> auxiliary stuff going on that you're not aware of (and can't really be
> aware of). To give an example off the top of my head, the nib-loading
> mechanism probably has a list of objects that it's going to send
> "awakeFromNib" to, which are held temporarily in an NSArray (which
> retains its contents).
>
> For this reason and many others, you should *never* rely on the
> retainCount to give you any useful information. Seriously, just don't
> even call that method, ever.  All you need to do is make sure your
> alloc/copy/retain calls are each matched by a corresponding
> release/autorelease somewhere, which it looks like they are in your
> code (using properties helps a lot).
>
> > 2. No matter wether I quit the program from my iPhone simulator or I quit
> > the simulaor, none of the
> > dealloc method is invoked because there is no any NSLog output from the
> > deallocmethod to the console.
> > Why? I know this probably can be solved if I have the retain count as I
> > expected.
>
> This is normal behavior for both Cocoa apps on Mac OS X, and iPhone
> apps. Rather than manually freeing a lot of memory, byte by byte
> (which will all be freed in one fell swoop when the process exits
> anyway), an app that is quitting just quits, which is a lot faster.
> If there's something in particular you need to do when the app quits
> (saving some data or something) you should implement one of the
> UIApplicationDelegate methods that tells you when the application is
> about to terminate.
>
> --
> // jack
> // http://nuthole.com
> // http://learncocoa.org
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Regarding MVC design pattern
      • From: Jack Nutting <email@hidden>
References: 
 >Regarding MVC design pattern (From: Sai <email@hidden>)
 >Re: Regarding MVC design pattern (From: Henry McGilton <email@hidden>)
 >Re: Regarding MVC design pattern (From: Sai <email@hidden>)
 >Re: Regarding MVC design pattern (From: Jack Nutting <email@hidden>)
 >Re: Regarding MVC design pattern (From: Sai <email@hidden>)
 >Re: Regarding MVC design pattern (From: Kyle Sluder <email@hidden>)
 >Re: Regarding MVC design pattern (From: Sai <email@hidden>)
 >Re: Regarding MVC design pattern (From: Jack Nutting <email@hidden>)

  • Prev by Date: Re: Regarding MVC design pattern
  • Next by Date: Re: Regarding MVC design pattern
  • Previous by thread: Re: Regarding MVC design pattern
  • Next by thread: Re: Regarding MVC design pattern
  • Index(es):
    • Date
    • Thread