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

Glib GIOChannel -

jsp - java.sql.SQLException: [Microsoft][ODBC Microsoft Access > Driver] Too few parameters. Expected 1 -

delphi - When I encode/decode SMS PDU (GSM 7 Bit) user data, do I need prepend the UDH first? -