• 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: There's obviously something I don't understand about NSDate.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: There's obviously something I don't understand about NSDate.


  • Subject: Re: There's obviously something I don't understand about NSDate.
  • From: Charles Srstka <email@hidden>
  • Date: Sat, 17 Mar 2012 18:23:18 -0500

On Mar 17, 2012, at 6:10 PM, G S wrote:

> Thanks, Dave.  That's what I thought.  But I don't understand why I need to
> retain it then; it's assigned to a member pointer.  Why does it get
> released, and when?

Assigning something to an instance variable doesn’t cause it to get retained unless you’re building for ARC. For manual retain-release, you have to retain it yourself or it will get released at some indeterminate time in the future.

>  If I call retain on it, do I have to call release on
> it later?

Yes (again, unless you’re using ARC). Do it in your -dealloc method.

> I create another NSDate, on the stack, to hold "now" for use within that
> function.  Do I need to retain that too?

Yes.

It would be a good idea to read Apple’s Memory Management documentation before going any further, really.

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html

Charles

_______________________________________________

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: There's obviously something I don't understand about NSDate.
      • From: G S <email@hidden>
    • Re: There's obviously something I don't understand about NSDate.
      • From: Roland King <email@hidden>
References: 
 >There's obviously something I don't understand about NSDate. (From: G S <email@hidden>)
 >Re: There's obviously something I don't understand about NSDate. (From: Dave Fernandes <email@hidden>)
 >Re: There's obviously something I don't understand about NSDate. (From: G S <email@hidden>)

  • Prev by Date: Re: There's obviously something I don't understand about NSDate.
  • Next by Date: Re: There's obviously something I don't understand about NSDate.
  • Previous by thread: Re: There's obviously something I don't understand about NSDate.
  • Next by thread: Re: There's obviously something I don't understand about NSDate.
  • Index(es):
    • Date
    • Thread