在一個課程中,列出了包含所有朋友及其ID的列表。現在,當您單擊UITableView中的項目時,會出現「聊天」([self performSegueWithIdentifier: @"showChat" sender: self];
)。但是在ChatViewController類中,我需要從FirstViewController訪問變量userID。我嘗試了我在互聯網上找到的所有內容,但它總是給出錯誤或變量爲空。 在FirstViewController是一個NSString userid
,所以我怎麼能在ChatViewController.m中訪問這個?我試圖使變量@public
,我試圖@property
與readwrite等,但它不起作用。 例如對於這一點:將NSString授予其他課程
FirstViewController *fvc = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
userID = fvc.userID;
只是給出了一個空字符串..
感謝您的幫助!