hey, je suis actuellement en utilisant l'iPhone SDK et je vais avoir du mal à faire passer un NSString par 3 vuesComment transmettre un NSString à 3 ViewControllers?
Je suis en mesure de passer un NSString entre 2 contrôleurs de vue mais je ne peux pas passer par un autre. Mon code est le suivant ...
`- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)index`Path {
NSString *string1 = nil;
NSDictionary *dictionary = [listOfItems objectAtIndex:indexPath.section];
NSArray *array = [dictionary objectForKey:@"items"];
string1 = [array objectAtIndex:indexPath.row];
//Initialize the detail view controller and display it.
ViewController2 *vc2 = [[ViewController2 alloc] initWithNibName:@"ViewController2" bundle:[NSBundle mainBundle]];
vc2.string1 = string1;
[self.navigationController pushViewController:vc2 animated:YES];
[vc2 release];
vc2 = nil;
}
dans les « viewController 2 » implémentations Je suis en mesure l'utilisation « string1 » dans la barre de titre en procédant comme suit ....
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = string1;
UIBarButtonItem *addButton = [[[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"icon_time.png"]
style:UIBarButtonItemStylePlain
//style:UIBarButtonItemStyleBordered
target:self
action:@selector(goToThirdView)] autorelease];
self.navigationItem.rightBarButtonItem = addButton;
}
mais je également un bouton de navigation sur le côté droit que je voudrais pousser une nouvelle vue
- (void)goToThirdView
{
ViewController3 *vc3 = [[ViewController3 alloc] initWithNibName:@"ViewController3" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:NESW animated:YES];
vc3.string1 = string1 ;
[vc3 release];
vc3 = nil;
}
Comment puis-je passer sur la même chaîne à la troisième vue? (ou quatrième)