//查看源文件有3个属性
@property (nonatomic, readonly) NSString *identifier; //标识
@property (nonatomic, readonly) id sourceViewController; //源窗口
@property (nonatomic, readonly) id destinationViewController; //目标窗口
/* 默认会生成此方法
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
实现:
/*
#pragma mark - Navigation
*/
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
NSLog(@"调用B");
NSDateFormatter *dateformate = [[NSDateFormatter alloc] init ];
[dateformate setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSString *showdate =[dateformate stringFromDate:[NSDate date]];
//@2调用窗口
[[segue destinationViewController] setNumber:showdate];
}
NSLog(@"%@aaa", [segue identifier]);
打印老是空指针操作,后来通过方法找到需要如下设置: