将值从选定的行传递

将值从选定的行传递

我尝试将值从选定的行传递给视图控制器。日志在新的视图控制器中返回空值。我的错误在哪里?

 2013-06-18 17:28:59.394 App[1790:c07] ID is Here: 35023

 2013-06-18 17:28:59.397 App[1790:c07] Value in Next view  (null)

2013-06-18 17:28:59.398 App[1790:c07] Label is Here <UILabel: 0x9139810;
frame = (14 140; 255 16); clipsToBounds = YES; opaque = NO;
autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x915ab10>>

TableViewController代码:
NSString *localStringValue;

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSUInteger row = [indexPath row];
    NSString *value = [myArray objectAtIndex:row];

    DetailViewController *second=[[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil] ;

    second.PassID=value;

    [self presentModalViewController:second animated:YES];

    localStringValue = [tableView cellForRowAtIndexPath:indexPath].textLabel.text;
    NSLog(@"ID is Here: %@", value);
}

Next View控制器代码:

。H
@interface DetailViewController : UIViewController
{
    NSString *PassID;
}
@property (nonatomic, retain) NSString *PassID;
@property (unsafe_unretained, nonatomic) IBOutlet UILabel *label;

.m代码
- (void)viewDidLoad
{

   label.text=PassID;
    NSLog(@"Label is Here %@",label);

    [super viewDidLoad];
}

最佳答案

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSUInteger row = [indexPath row];
    NSString *value = [myArray objectAtIndex:row];

    DetailViewController *second=[[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil] ;

/// second.PassID=value; ///Remove the line here


    [self presentModalViewController:second animated:YES];

    second.PassID=value; ///assign the value after presenting


    localStringValue = [tableView cellForRowAtIndexPath:indexPath].textLabel.text;
    NSLog(@"ID is Here: %@", value);
}

10-04 21:59