https://github.com/brookswon/btnsdateformatterfactory
https://github.com/brookswon/btnsdateformatterfactory
memory nscache nsdateformatter
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/brookswon/btnsdateformatterfactory
- Owner: BrooksWon
- License: mit
- Created: 2018-01-04T10:02:11.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-05T07:33:31.000Z (over 8 years ago)
- Last Synced: 2025-03-21T15:12:24.206Z (about 1 year ago)
- Topics: memory, nscache, nsdateformatter
- Language: Shell
- Size: 122 KB
- Stars: 25
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BTNSDateFormatterFactory
Smart reuse of NSDateFormatter instances.
`NSDateFormatter` class is very useful to display dates the way you want, handling regional settings, locales and formats.
The bad thing about `NSDateFormatter` is the cost to create a new instance or set format and locale. Actually these actions are one of the most slow operations on iOS SDK and you really must avoid it.
`DFDateFormatterFactory` is here to help you with this. This class retain the last 15 date formatter instances and return the already loaded based on format and locale you want. Also, the cache were implemented using the standard `NSCache` and should handle memory fine when memory warnings happens.
## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Requirements
## Installation
`BTNSDateFormatterFactory` is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:
```
pod 'BTNSDateFormatterFactory'
```
or
To install the `BTDateFormatterFactory`, just drag and drop the .h and .m files into your project folder. Import them when you need it.
## Usage
```
NSDateFormatter *dateFormatter = [[BTNSDateFormatterFactory sharedFactory] dateFormatterWithFormat:@"yyyy-MM-dd" andLocaleIdentifier:@"zh_CN"];
```
## Author
BrooksWon, jianyu996@163.com
## License
BTNSDateFormatterFactory is available under the MIT license. See the LICENSE file for more info.