ios - In ARC, what happens to the memory of an object that is reinitialized? -


let's have method called test.

test{     nsstring *answer = [[nsstring alloc] initwithstring:@"value 1"];     answer = [[nsstring alloc] initwithstring:@"value 2"]; } 

when answer got reinitialized, happens memory of first initialization under arc?

the first string released (the string created in [[nsstring alloc] initwithstring:@"value 1"];)

answer in case object strong ownership qualification. docs, happens when assign answer:

for __strong objects, new pointee first retained; second, lvalue loaded primitive semantics; third, new pointee stored lvalue primitive semantics; , finally, old pointee released. not performed atomically; external synchronization must used make safe in face of concurrent loads , stores.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -