CZDateFormatterCache 1.2

CZDateFormatterCache 1.2

TestsTested
LangLanguage Obj-CObjective C
License Apache 2
ReleasedLast Release Dec 2014

Maintained by Peyman Oreizy.


Downloads

Total2,925
Week5
Month39

Installs

Apps37
Apps WeekApps This Week 2
Test Targets7
Test WeekTests This week 1
Watch Apps1
powered by Segment

GitHub

Stars17
Watchers27
Forks1
Issues0
Contributors3
Pull Requests0

Code

Files2
LOCLines of Code 133


  • By
  • Peyman Oreizy and Brian Cooke

Anyone who has profiled scroll performance of a UITableView whose cells render dates knows how slow it is create NSDateFormatter instances. CZDateFormatterCache creates a global cache of NSDateFormatter instances -- created the first time you use the cache -- that can be shared by all of your UI code, as in:

NSDate *date = ...;

cell.detailTextLabel.text = [[CZDateFormatterCache mainThreadCache] localizedStringFromDate:date dateStyle:kCFDateFormatterShortStyle timeStyle:kCFDateFormatterShortStyle];

Since NSDateFormatter instances are not thread safe, you should only use the cache from the "main" thread. In fact, CZDateFormatterCache asserts if you try to use the cache from another thread.

Credits

CZDateFormatterCache was created by Peyman Oreizy and Brian Cooke in the development of CareZone Mobile for iOS.

Contact

Peyman Oreizy @peymano

Brian Cooke @bricooke

License

CZDateFormatterCache is available under the Apache 2.0 license. See the LICENSE file for more info.