あるViewControllerから別のViewControllerにデータを渡そうとしています。NSMutableDictionaryを別のビューに渡す
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
}
私を助けてください。私は間違っている。
AppointmentDictionary = (null)
はviewwillappear
になります。 私はこれを正しくコピーしていますが。
これは何度か聞かれていますが、利用可能なSOの投稿を見ましたか? –
ここで間違ったことがたくさんありますが、どのようにvcを初期化するかは間違っていますし、segueを呼び出すために初期化する必要はなく、 'prepareForSegue'からデータを渡す必要があります。最後に関数とプロパティ名を小文字にしてください。 – Tj3n
@ Tj3nコメントありがとうございます。私はプロパティと関数名を変更します。 prepareForSegueからデータを渡す必要がありますか?私は理解していなかった。 –