I have multiple .xib files and multiple view controllers.
Problem is when I pass data to parent View Controller from a Subview, Data is successfully passed. But when i switch to another Subview and come back to parent view controller data that has been passed loss.
I keep passed data in an NSMutablearray, so How should I back up passed data that it wont loss when i switch views?
ForStand Button is the NSMutablearray that keeps incoming data from the subview and as seen below it turns to null when i switch to another subview and come back to main view.
Here is the example output:
2012-03-06 13:44:38.184 Avicii[726:b603] ForStand Button = '(null)'
server did not accept client registration 68
2012-03-06 13:44:41.809 Avicii[726:b603] StandLocations (
"Point Stand",
"Near Stand"
)
2012-03-06 13:44:43.252 Avicii[726:b603] ForStand Button = 'Near Stand'
server did not accept client registration 68
2012-03-06 13:44:56.984 Avicii[726:b603] ForStand Button = '(null)'
server did not accept client registration 68
in Subview data passes as following:
- (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath {
StartHuntViewController *startHuntController = [[StartHuntViewController alloc] initWithNibName:@"StartHuntView" bundle:nil];
startHuntController.forStandButton = [stands objectAtIndex:indexPath.row];
startHuntController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:startHuntController animated:YES];;
// startHuntController.standLocation.text=[stands objectAtIndex:indexPath.row];
[startHuntController release];
startHuntController =nil;
}
In parent ForStand is initilazed as following
in .h
@property (nonatomic, retain)NSMutableArray *forStandButton;
in .m
@synthesize forStandButton;
Your parent view controller data variables might be getting released in case of memory consumptions…
I will suggest creating the variables in
Appdelegateand setting it using theor making a new singleton class only to store this data..