objective c - Copying NSDate objects and releasing -


if this:

nsdate *datestart; [datestart alloc];  // initialise date somewhere here..  ..  // modify start date. datestart = [chosendate copy]; 

should doing [datestart release] before assigning datestart pointer?

i'm c/c++ background , don't understand whole objectivec/ios garbage collection behaviour (if indeed there any). c background telling me should freeing initial nsdate object datestart pointing to. correct?

yes since allocated before should release before line

//release before reassign [datestart release]; datestart = [chosendate copy]; 

also notice preferred allocation , initialization on same line, dont break them multiple lines

so this

nsdate *datestart; [datestart alloc]; 

would change to

nsdate *datestart = [[datestart alloc] init....]; 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -