Re: Need localization-proof method of transporting dates.
Re: Need localization-proof method of transporting dates.
- Subject: Re: Need localization-proof method of transporting dates.
- From: Ricky Sharp <email@hidden>
- Date: Wed, 08 Apr 2009 06:52:00 -0500
You can always specify the specific locale to use in a custom sorting
method.
Sent from my iPhone
On Apr 8, 2009, at 6:46 AM, Graham Cox <email@hidden> wrote:
On 08/04/2009, at 2:45 PM, Graham Cox wrote:
Thanks for all your help - just remains to be seen now if certain
users can now open my app! ;)
It occurs to me that there is another potential problem that I've
overlooked. System locale affects sorting, right? At least the
comment in the System Preferences > International suggests that to
be the case, and it makes sense of course.
So when I hash a dictionary, I sort the keys to ensure a consistent
order for the items, but if the sorting can vary with locale, I'm
going to be stuffed. Is there a locale-proof way to sort the keys?
The current code is:
@implementation NSDictionary (GCHash)
- (NSData*) gc_hash
{
NSMutableData* data = [NSMutableData data];
NSMutableArray* keys = [[self allKeys] mutableCopy];
[keys
sortUsingSelector:@selector(caseInsensitiveCompare:)]; //
<<----------- potential problem????
NSEnumerator* iter = [keys objectEnumerator];
id key;
id obj;
while(( key = [iter nextObject]))
{
[data appendData:[key gc_hash]];
obj = [self objectForKey:key];
[data appendData:[obj gc_hash]];
}
[keys release];
return data;
}
@end
--Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden