I’m trying to make a transition between two ViewControllers using a Navigation Controller, the object referenced by segue.destinationViewController is: 0x1cd93590 (the next view), but when the change is made to the newly view this has a different number of object: 0x1cd4556d0. My code is:
- (void)updateCodeProduct:(NSString *)code {
[session stopRunning];
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
AudioServicesPlaySystemSound(1111);
// db acces.
NSString *cadena = @"http://172.20.10.2/consultaProd.php?codigo=";
cadena = [cadena stringByAppendingString:codigo];
NSURL *url = [NSURL URLWithString:cadena];
NSError *error = nil;
NSString *retorno = [[NSString alloc] initWithContentsOfURL:url encoding:NSASCIIStringEncoding error:&error];
if (retorno == nil) {
NSLog(@"Error %@\n%@", url, [error localizedFailureReason]);
return;
}
self.detailProd = nil;
self.detailProd = [retorno componentsSeparatedByString:@"\n"];
[self performSegueWithIdentifier:@"DetailSegue" sender:self];
}
The prepareForSegue method is:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSLog(@"%@", [segue destinationViewController]);
if ([segue.identifier isEqualToString:@"DetailSegue"]) {
[segue.destinationViewController updateDetail:detailProd];
}
}
The segue is performed, but the view does not reflect the current information, because is a different object.
Any Help will be appreciated 🙂
What does the
updateDetailmethod do? If it’s trying to update a control in the destination controller, it’s too early to do that, since the controls won’t have been created yet. You just want to set properties (e.g. aNSStringor whatever) in the destination controller. The destination controller should then take that property and update its controls inviewDidLoadof that destination controller.In short, the address of the destination controller will be the same as address of the view controller itself. You don’t show us your
NSLogstatements for those two addresses you’re reporting, so it’s impossible for us to say what’s going on there.