-1

主视图控制器.h

NSString *quality;

主视图控制器.m

#import DetailViewController.h

-(void)viewDidLoad {
    quality = [NSString stringWithFormat:@"string to pass"];

    ...

}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"showDetail"]) {
        DetailViewController *detailView = [segue destinationViewController];

        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];

        theList = [app.listArray objectAtIndex:indexPath.row];

        detailView.theList = theList;

        detailView.streamQuality = quality;

    }
}

DetailViewController.h

@property (nonatomic ,retain) NSString *streamQuality;

细节视图控制器.m

@synthesize streamQuality;

NSLog(@"Final: %@", streamQuality);

输出:大多数我得到“线程1:EXC_BAD_ACCESS(代码= 2,地址= 0x10)”
或随机的东西,如“最终:复制音频地址”



但是,这很好用:

detailView.streamQuality = @"hello";
4

1 回答 1

1

您应该创建一个属性来保留NSStringObject quality。例如:

@property (nonatomic ,copy) NSString *quality;

当然你必须合成它:

@synthesize quality;

然后你应该使用这个属性来设置字符串。像这样 :

self.quality = @"string to pass";
于 2013-09-17T10:44:56.960 回答