I seem to be going in circles around this problem and I am heading no where now.
I am trying to force the language of my app (to swedish) as shown below.
@autoreleasepool {
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"sv", nil] forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults]synchronize];
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
I have done it in the main method, so that preference is set as soon as the application is launched.
Then when i want to sort an array alphabetically i use NSSortDescriptor with selector localizedCaseInsensitiveCompare:.
NSSortDescriptor *valueDescriptor = [[NSSortDescriptor alloc] initWithKey:@"iName" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
NSArray * descriptors = [NSArray arrayWithObject:valueDescriptor];
self.ingredientsList = [NSMutableArray arrayWithArray:[self.ingredientsList sortedArrayUsingDescriptors:descriptors]];
But my problem is sorting with my local language does not happen the first time. But if I restart the app, the sorting is according to the language (Swedish). Why doesnt it happen the first time?
What am i doing wrong?
Help/suggestions will be appreciated. Thanks