• 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: Beginner Question Re: Memory Management
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Beginner Question Re: Memory Management


  • Subject: Re: Beginner Question Re: Memory Management
  • From: Ken Thomases <email@hidden>
  • Date: Tue, 23 Jun 2009 00:14:20 -0500

On Jun 22, 2009, at 3:39 PM, Daniel Torrey wrote:

I'm looking at some sample iPhone code, and in the app delegate's applicationDidFinishLaunching method, I see

// Set up the view controller
MyViewController *aViewController = [[MyViewController alloc] initWithNibName:@"HelloWorld" bundle:[NSBundle mainBundle]];
self.myViewController = aViewController;
[aViewController release];


I'm a little confused - I see an allocation, followed by an assignment, followed by a release. I think that the assignment is really a call to a setter - the myViewController field is created automagically using the @property/@synthesize syntax.

The expression "self.myViewController" is using "dot syntax". Objective-C 2.0 dot syntax always resolves to accessor calls. It is not a consequence of using declared properties, synthesized or not. It works even with old-style, manually-written properties and accessors.


That said, the property declaration gives you good information about the semantics of how the property behaves -- again, regardless of whether it's synthesized or implemented manually. In this case, it should tell you that the property retains what's assigned to it, which is why the view controller is not deallocated while it's still being used.

Cheers,
Ken

_______________________________________________

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


References: 
 >Beginner Question Re: Memory Management (From: Daniel Torrey <email@hidden>)

  • Prev by Date: Re: Warnings suggest compiler confusion between 32 and 64 bit code.
  • Next by Date: Re: Beginner Question Re: Memory Management
  • Previous by thread: Re: Beginner Question Re: Memory Management
  • Next by thread: IKImageBrowserView setSelectionIndex not selecting
  • Index(es):
    • Date
    • Thread