-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding basic i18n support #15
Conversation
Hi @billymeltdown, today I've been rebasing #14. I believe the |
To be honest I haven't thought real hard about thread concurrency with these helpers methods, although I'm not running into any issues. If you'd like to point out what's problematic with the current setup and suggest some fixes that would be great!
Could you expand on that some more? All in all, this is a krufty category. I recently came across Erica Sadun's NSDate-Utilities category and it looks quite cleanly implemented, using a shared calendar but not a shared formatter: https://github.com/erica/NSDate-Extensions/blob/master/NSDate%2BUtilities.m |
Did a little reading and you are right, NSDateFormatter has not been thread-safe. However, it is in the very latest APIs (iOS 7 and OS X 10.9 Mavericks): So we'll want to fix this to be thread-safe for older deployment targets, as not everyone is targeting only the latest and greatest (myself included). If you have the time and you want to take a crack at some of it, it'd be a big help! I'll try to bang this out in the near future. |
I would gladly contribute to fix it, but I'm afraid I don't fully understand yet the implications of mutating a shared date formatter. I would probably suggest to use a different shared formatter for each I also thought about having a pool of formatters, but this solution seemed a bit over engineered. I am sure there must be a smarter way for dealing with the thread safety issue, but it's simply beyond my knowledge. |
Well I think the first thing to do is get rid of the shared formatter since that's a no-go before 10.9 and iOS 7, and replace each with individual NSDateFormatter objects to start with. From there we can consider what needs to be optimized, what can be shared because it's never intended to be mutated (e.g. if the user is asking for a format, we need a new formatter, otherwise maybe not). I remember when this was first suggested, sharing the formatter, it was because it was getting too expensive to use the category due to all the formatter objects created. I suspect that maybe we just shouldn't be doing this and the application code should be handling, but maybe we can thread the needle. |
No description provided.