Keep UITableView selected value after data reload
I have a table that is loading values from a JSON call that refreshes every 5 seconds. Every time the table changes, and a new cell is added, the currently selected cell becomes the one above the last one on the reload. You can see in my get_counter selector where I am trying to do it. Thanks in advance! I am still very new at ObjC so just trying to learn :)

    - (void)viewDidLoad {
    [super viewDidLoad];
    repeat_timer=[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(check_new) userInfo:nil repeats:YES];

}

    -(void)check_new{

		NSString *ret;
		ret=[MyWebFunction is_new_orders:appDelegate.user_id Order_number:[[response_array objectAtIndex:0] objectForKey:@"order_id"] Type:type];
	
		if([ret isEqualToString:@"yes"]){
			[indicator startAnimating];
			[self performSelector:@selector(get_counter) withObject:nil afterDelay:0.0005];
	                                      		
		}
	}


    -(void)get_counter{

	jsonString = [[NSMutableString alloc] initWithData:[MyWebFunction get_orders:appDelegate.user_id Type:type Limit:limit] encoding:NSUTF8StringEncoding];;
	response_array = [[jsonString JSONValue] retain];
	[indicator stopAnimating];

    //this is my attempt at retaining the value :)    
    NSIndexPath *ipath = [table indexPathForSelectedRow];
    NSLog(@"iPath: %@",ipath);
	[table reloadData];
    [table selectRowAtIndexPath:ipath animated:NO scrollPosition:UITableViewScrollPositionNone];
    
	
	if([response_array count]>0){
	
		total=[[[response_array objectAtIndex:0] objectForKey:@"total_orders"] intValue];
		checksArray=[[NSMutableArray alloc] init];
		
		for(int i=0;i<response_array.count;i++){
			
			[checksArray addObject:@"0"];
		}
	}
	sel_item_id=[[NSMutableArray alloc] init];
	all_ids=nil;
	
	if(repeat_timer){
		[repeat_timer invalidate];
		repeat_timer=nil;
	repeat_timer=[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(check_new) userInfo:nil repeats:YES];
	}

}


Keep UITableView selected value after data reload
===

I have a table that is loading values from a JSON call that refreshes every 5 seconds. Every time the table changes, and a new cell is added, the currently selected cell becomes the one above the last one on the reload. You can see in my get_counter selector where I am trying to do it. Thanks in advance! I am still very new at ObjC so just trying to learn :)

    - (void)viewDidLoad {
    [super viewDidLoad];
    repeat_timer=[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(check_new) userInfo:nil repeats:YES];

}

    -(void)check_new{

		NSString *ret;
		ret=[MyWebFunction is_new_orders:appDelegate.user_id Order_number:[[response_array objectAtIndex:0] objectForKey:@"order_id"] Type:type];
	
		if([ret isEqualToString:@"yes"]){
			[indicator startAnimating];
			[self performSelector:@selector(get_counter) withObject:nil afterDelay:0.0005];
	                                      		
		}
	}


    -(void)get_counter{

	jsonString = [[NSMutableString alloc] initWithData:[MyWebFunction get_orders:appDelegate.user_id Type:type Limit:limit] encoding:NSUTF8StringEncoding];;
	response_array = [[jsonString JSONValue] retain];
	[indicator stopAnimating];

    //this is my attempt at retaining the value :)    
    NSIndexPath *ipath = [table indexPathForSelectedRow];
    NSLog(@"iPath: %@",ipath);
	[table reloadData];
    [table selectRowAtIndexPath:ipath animated:NO scrollPosition:UITableViewScrollPositionNone];
    
	
	if([response_array count]>0){
	
		total=[[[response_array objectAtIndex:0] objectForKey:@"total_orders"] intValue];
		checksArray=[[NSMutableArray alloc] init];
		
		for(int i=0;i<response_array.count;i++){
			
			[checksArray addObject:@"0"];
		}
	}
	sel_item_id=[[NSMutableArray alloc] init];
	all_ids=nil;
	
	if(repeat_timer){
		[repeat_timer invalidate];
		repeat_timer=nil;
	repeat_timer=[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(check_new) userInfo:nil repeats:YES];
	}

}

