4 ms·
Emphatic agreement about NSDateFormatter. Be careful about instantiating too many of those. I wrote an import class to map some JSON to Core Data entities, inc
by danilocampos 16y ago
Emphatic agreement about NSDateFormatter. Be careful about instantiating too many of those.
I wrote an import class to map some JSON to Core Data entities, including a boatload of dates. NSDateFormatter instances were being created during several loops, at a cost of about 800ms, according to Time Profiler.
Refactored the code to use a single instance, shared across every object and method that needed to do date parsing or other date chores. Shaved that 800ms down to about 90.
Check your Cocoa codebase for NSDateFormatter abuse – really easy win.
Another win: Have your server vend binary Plist files instead of JSON or XML. Zero parsing needed, similar file sizes. Cut import times as much as 50%!