【发布时间】:2017-05-20 20:50:34
【问题描述】:
我正在尝试将数据从一个 ViewController 传递到另一个 ViewController。
Firstviewcontroller.m
-(void)NavigateToAnotherScreen:(NSMutableDictionary*)dict{
[self performSegueWithIdentifier:@"NavDashBoardToInfo" sender:self];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"NavDashBoardToInfo"])
{
InfoViewController *vc = [segue destinationViewController];
[vc setAppointmentDictionary:dict];
}
}
Secondviewcontroller.h
@property (strong, nonatomic) NSMutableDictionary *AppointmentDictionary;
Secondviewcontroller.m
@synthesize AppointmentDictionary;
- (void)viewWillAppear:(BOOL)animated{
NSLog(@"dict===>%@",AppointmentDictionary); // This gives me null
}
请帮助我。我做错了什么。
我在viewwillappear 中收到AppointmentDictionary = (null)。
虽然我正在做这个的正确副本。
【问题讨论】:
-
这个问题已经被问了好几次了,你有没有看可用的 SO 帖子?
-
这里有这么多错的地方,你怎么初始化vc是错的,而且你不需要初始化它来调用segue,你必须从
prepareForSegue传递数据,最后是函数和属性名称应为小写 -
@Tj3n 感谢您的评论。我将更改属性和函数名称。必须从 prepareForSegue 传递数据?我不明白。
-
查看这里stackoverflow.com/questions/7864371/…>
标签: ios objective-c copy nsmutabledictionary