我有兩個賽段離開了我的初始視圖控制器。 push segue連接到單元格,模式連接到+ UIBarButtonItem。prepareForSegue在調用時不發送參數,導致崩潰
當這是我prepareForSegue的代碼是什麼樣子,一切都很好,filepath是通過推SEGUE發送,但文件路徑不通過模式SEGUE通過。
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showTimes"]) {
[[segue destinationViewController] setFilePath:filePath];
}
// if ([[segue identifier] isEqualToString:@"addEvent"]) {
// [[segue destinationViewController] setFilePath:filePath];
// }
}
如果我取消註釋第二個if語句和segue標識符,則應用程序崩潰。 filePath無處發送。我已經嘗試將[[segue destinationViewController] setFilePath:filePath];
移出兩個if語句,以確保該行被執行,但這也會使我的應用程序崩潰。
這兩個seg都在屬性中設置了正確的標識符。但是,我不確定Xcode實際上是否意識到設置了正確的標識符,因爲當我更改segue類型時,下次運行應用程序時不會反映這些更改。
我不知道該怎麼做。 Objective-C相對而言是新手。
更換第二,如果有別的,如果 – zaheer
我試過'別人if'太多,但它給出了相同的結果時,它的註釋掉的。我試過把它改成'else',但是這似乎也不起作用。 – waterproofpiano
查看下面的Jason Coco的答案,如果這不起作用,請分享日誌中顯示的崩潰原因。 – zaheer