indexPath.row の値を保存しようとしていますが、次のビューでは 0 になります。
selectedRecipiesViewController では、常にゼロを取得します。これが私のコードです。
MainRecipieViewController.h
@property (assign) int storageString ;
MainRecipieViewController.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (!self.selectedRecipiesViewController) {
self.selectedRecipiesViewController = [[[SelectedRecipiesViewController alloc] initWithNibName:@"SelectedRecipiesViewController" bundle:nil] autorelease];
}
if(indexPath.row == 0) {
self.selectedRecipiesViewController.passingArray = soupArray;
}
if (indexPath.row == 1) {
self.selectedRecipiesViewController.passingArray = seaFoodArray;
}
if (indexPath.row ==2) {
self.selectedRecipiesViewController.passingArray = meatMuttonArray;
}
storageString = indexPath.row;
NSLog(@"storageString %i",storageString);
[self.navigationController pushViewController:self.selectedRecipiesViewController animated:YES];
[tableView reloadData];
}
SelectedRecipiesViewController.m
- (void)viewWillAppear:(BOOL)animated {
NSLog(@"next view %i" ,self.vc.storageString);
}