I have one view where I read json data. and extract keys from it.
in – (void)viewDidLoad {
I do the following:
hotellat = [rows4 valueForKey:@"H_LAT"];
hotellon = [rows4 valueForKey:@"H_LON"];
Then I perform a push after the viewDidLoad like below:
- (IBAction)buttonClicked:(id)sender
{
NSLog(@"hotellat: %@",hotellat);
MapTutorialViewController *controller = [[MapTutorialViewController alloc] initWithNibName:@"MapTutorialViewController" bundle:[NSBundle mainBundle]];
controller.LAT = hotellat;
controller.LON = hotellon;
[self.navigationController pushViewController:controller animated:YES];
[controller release];
}
NSlog in this section shows that hotellat is null, but when I write the nslog in the viewDidload, there is a value. What is it that I need to do to get this variable to pass to next view? also this is a string, and I think I need to convert it to integer so I can assign it to the latitude in map view?
I also @synthesize hotellat, hotellon; in the controller and have the following in the .h file:
@property (nonatomic, retain) NSString *hotellat;
@property (nonatomic, retain) NSString *hotellon;
though you are using retained variables but retain message is not being sent to the values by this assignment:
use:
this way the retain message will be passed to the value and it will be ensured that it stays there until you release it explicitly.
later on you can release the values:
lets say after:
[controller release];