objective c - Convenience class method vs alloc init -


I understand that objects can work more efficiently if you can allocate and start them manually ( ARC should have taken care of the majority of this, okay?), Though, is it really big in the performance gap if you want to use the comfort category methods to create an object every time?

Example:

  NSSTING * message = [[NSSTring alloc] initWithFormat: @ "text% @", message];  

versus

  NSString * message = [NSString stringWithFormat: @ "text% @", message];  

There is no significant difference in performance.

Even there is a timely optimism worried about it and in the form of Donald Knuth: "Timely optimization is the root of all evils (or at least most) in programming."

Code clarity is a more important issue.


Comments