有时,我的应用程序在使用时会丢失所有数据:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
/*
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
*/
[tableView deselectRowAtIndexPath:indexPath animated:YES];
switch (indexPath.row)
{
case kLANG_HEBREW:
// Hebrew is the default
self.arrayOfLanguages = [NSMutableArray arrayWithObjects:@"he", @"en", nil];
break;
case kLANG_ENGLISH:
self.arrayOfLanShorts = [NSMutableArray arrayWithObjects:@"en", @"he", nil];
break;
case kLANG_RUSSIAN:
self.arrayOfLanShorts = [NSMutableArray arrayWithObjects:@"ru", @"en", nil];
break;
case kLANG_ARABIC:
self.arrayOfLanShorts = [NSMutableArray arrayWithObjects:@"ar", @"en", nil];
break;
}
[[NSUserDefaults standardUserDefaults] setObject:self.arrayOfLanShorts forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"come_from_change_lang"];
[[NSUserDefaults standardUserDefaults] synchronize];
[self.navigationController popToRootViewControllerAnimated:YES];
}
这很奇怪,因为我没有清除我的应用程序中的数据。