NSString *systemLanguate = [[[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0] substringToIndex:2];
NSString *localizationKey;
if ([systemLanguate isEqualToString:@"ja"]) {
localizationKey = @"ja";
} else if ([systemLanguate isEqualToString:@"ja"]) {
localizationKey = @"zh_TW";
} else {
localizationKey = @"en";
}
//如果array裡是NSDictionary的值要做排序可以用key.property來得到裡面的字串
NSString *descriptorKeyString = [NSString stringWithFormat:@"display_names.%@", localizationKey];
NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:descriptorKeyString ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
self.sortAry = [self.sortAry sortedArrayUsingDescriptors:@[descriptor]];
2015年10月15日 星期四
[iOS] NSMutableArray sort by localizations
根據各個語言對NSMutablewArray裡的字串做排列
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言