I want to use the value that I received after tapping a UITableCellView. I stored the value into arrays, and defined the instance of the ViewController of UITableCellView in order to reach those arrays. Even though I can reach the arrays from the other ViewController, it always write “0” as a result to the textfield I want to have the data. I need the exact data stored in the array. Here is the code how I tried to do it;
(fourthViewController)
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
NSString *msg = [[NSString alloc] initWithFormat:
@"%@ rate for %@ has been selected",
[rates objectAtIndex:[indexPath row]],
[countries objectAtIndex:[indexPath row]]];
UIAlertView *alert =
[[UIAlertView alloc] initWithTitle:@"New country selected"
message:msg
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
[msg release];
fCountry = [countries objectAtIndex:indexPath.row];
fRate = [rates objectAtIndex:indexPath.row];
}
The FirstViewController I’m trying to use the arrays;
@interface FirstViewController : UIViewController{
@public
...
FourthViewController *fourthViewController;
}
...
@property (nonatomic, assign) FourthViewController *fourthViewController;
@synthesize fourthViewController;
Thank you for your answers in advance!
You are declaring the whole ViewController as a property. Just use your arrays as properties.
Generally, there is a great tut for passing data: http://www.theappcodeblog.com/2011/04/15/passing-data-between-views-tutorial-using-a-protocol-delegate-in-your-iphone-app/