I would say kind of, but it could still be done better. Specifically, you could do: property (nonatomic, copy) NSDate* coreWeStart and then: self. CoreWeStart = self.
Start to get the same thing with less code. Also be sure to do self. CoreWeStart = nil in dealloc (and self.
Start = nil too).
I would say kind of, but it could still be done better. Specifically, you could do: @property (nonatomic, copy) NSDate* coreWeStart; ...and then: self. CoreWeStart = self.
Start; ...to get the same thing with less code. Also be sure to do self. CoreWeStart = nil in dealloc (and self.
Start = nil too).
I guess unless you want the coreWeStart property to refer to some other external property at some point in the future (ie the property is retain for some other reason). – RedBlueThing May 5 at 5:25 can I check: (a) is there any way around having to set them to nil in dealloc? (b) do you think using copy may lead to confusion later if developers don't monitor the way the property was set i.e.Is it mostly normal to use "retain" most of the time – Greg May 5 at 5:41 I generally like to explicitly release my memory (start release), rather than just setting to nil.
Problem with that approach is that if someone accidentally types start=nil instead of self. Start=nil, the memory will leak. – RedBlueThing May 5 at 5:44 For future developers it usually doesn't matter if you use retain or copy.
Since NSDate is immutable the only thing that copy will do is retain anyway. And I wouldn't consider retain normal. I usually use copy, except for mutable classes.
– fluchtpunkt May 5 at 5:47 1 @Greg - (a) Yes, you can call release on them, as per RedBlueThing's comment. (b) It depends on the developer, really.In general, copy is used for properties that might be subject to change elsewhere in the code. For instance, if you have a property of type NSString someone may pass you an NSMutableString instance and then change its value afterwards, which could cause issues if the property is declared as retain.
Declaring it as copy avoids the problem. That said, NSDate has no mutable subclass, so the "normal" declaration for NSDate properties is retain. – aroth May 5 at 5:56.
Yep. You got it. Copy returns a new object with a retain count of one.
Assigning it to the retain keyword property will increment the retain count. Autorelease will decrement the retain count. So your object has the coreWeStart property with a retain count of one, which is a copy of the start property.
You only need to use autorelease pools in a very small set of circumstances - you do not need it here. Also, why are you not using ARC, and stop working about autoreleasing items? In your code you would not autorelease "stringWithFormat" since the returned object is already autoreleased.
Seriously, I used retain/release/autorelease for years and years, switched to ARC last summer, and would never go back to the old ways. Let the system do the hard work for you!
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.