Initialize the new view controller with the value.
- (id)initWithValue:(int)someValue {
if (self = [super initWithNibName:@"MyViewController" bundle:nil]) {
myValue = someValue;
}
return self;
}
Then from your other view controller (assuming this other view controller is owned by a UINavigationController
)
- (void)showNextViewControler {
MyViewController *vc = [[[MyViewController alloc] initWithValue:someValue] autorelease]
[self.navigationController pushViewController:vc animated:YES];
}
And/or to do it after initialization, create a method or property that allows you to set it.
- (void)setSomeValue:(int)newValue {
myValue = newValue;
}
Then
- (void)showNextViewControler {
MyViewController *vc = [[[MyViewController alloc] initWithNibName:@"Foo" bundle:nil] autorelease]
[vc setValue:someValue]
[self.navigationController pushViewController:vc animated:YES];
}