iOS 2 Ragavan iOS 2 Ragavan - 2 months ago 6
iOS Question

How to pass latitude value to next view in iphone?

I have got response from services and I have got latitude value and I copied into an array.
Now I want to pass the array when I click the next views row.

I passed places earlier. In second view

UITableViewController
is there if I click the particular row then it should be printed the rows text value and particular text's latitude value.....?
Is this possible...

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

NSString *myText=[places objectAtIndex:indexPath.row];
NSLog(@"his is selected lattidude value:%@",myText);}


Here I am printing the row's text with this I need to print the latitude value of each one....please help me.

Answer

in your SecondViewController in .h file just

@interface SecondViewController : UIViewController{
     NSString *strLatLong;
}

@property (nonatomic, retain) NSString *strLatLong;

@end

and in .m file just synthesize it like bellow..

@synthesize *strLatLong

and in your FirstViewController class just push with bellow code

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    NSString *myText=[places objectAtIndex:indexPath.row];
    NSLog(@"his is selected lattidude value:%@",myText);
    SecondViewController *objSecondView = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
    objSecondView.strLatLong = myText;
    [objSecondView.strLatLong retain];
    [self.navigationController pushViewController:objSecondView animated:YES];
    [objSecondView release];

}

i hope this help you...