StringWithFormat vs initWithFormat under ARC

stringWithFormat: is a method of the NSString class and returns a string with auto-implementation; initWithFormat: is an instance method, and before ARC, the programmer had to take care of managing the memory of the returned object. If we included ARC, what is the difference between the two methods?

+4
source share
2 answers
+3
source

If ARC is enabled, there should be no difference.

Usually you call initWithFormat: after you have allocated your NSString, so the count without ARC will be 1 more than if you used the auto-implemented class method to create your own string (this way, you should free it).

There is no difference with ARC, because save / release / auto-detection is fully processed for you.

+1
source

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


All Articles