stringWithFormat:
is a class method of NSString
, and returns an autoreleased string; initWithFormat:
is an instance method, and before ARC the programmer had to take care of the returned object's memory management. If we have ARC turned on, what is the difference between the two methods?
相关问题
- CALayer - backgroundColor flipped?
- What uses more memory in c++? An 2 ints or 2 funct
- Core Data lightweight migration crashes after App
- back button text does not change
- Achieving the equivalent of a variable-length (loc
相关文章
- 现在使用swift开发ios应用好还是swift?
- TCC __TCCAccessRequest_block_invoke
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- How can I add media attachments to my push notific
- didBeginContact:(SKPhysicsContact *)contact not in
- Custom Marker performance iOS, crash with result “
- Converting (u)int64_t to NSNumbers
With ARC, these two methods are equivalent.
See:
If ARC is turned on there should be no difference.
You would typically call
initWithFormat:
after you've allocated your NSString, so the retain count without ARC would be 1 greater than if you used the autoreleased class method to create your string (thus you would have to remember to release it).With ARC, there is no difference, because retain/release/autorelease is completely handled for you.