IOS / iPhone ARC Memory Management

__weak NSString *strin = [[NSString alloc] initWithFormat:@"hey"] ; NSLog(@"weak %@",strin); //returns weak (null) __weak NSString *strin =@ "hey"; NSLog(@"weak %@",strin); //returns weak hey 

What is the difference between both fragments. Why does the second return value when assigning a slide?

+4
source share
2 answers

This is because @"hey" is a constant string literal that will be forever, while a weak link to the first (highlighted) line is not enough to save it.

+4
source

Check below and you will receive your answer.

enter image description here

+1
source

Source: https://habr.com/ru/post/1485802/


All Articles