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

mod rewrite - Using "?" when rewriting the URL -

.htaccess: Transfer name to index.php if not directory public -

Admob integration with pygame in android -