2013-12-13 98 views
0

我使用的是主從模板上的iPad應用程序的工作之間傳遞數據的主tableview是將數據傳遞給第二tableviewControlleriOS版:雙的UITableViewController用故事板

目前是我:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
    { 
    UITableViewController *secondTableView = [segue destinationViewController]; 
    } 

我的問題是。爲什麼當我嘗試在secondTableView訪問屬性,例如:

secondTableView.myString = @"goodBye";

我得到這個錯誤:

Property "myString" not found on object of type "UTableViewController".

我的問題是我怎麼能解決這個問題,或者是解決這個錯誤的方式。

我會很感激你的幫助

+0

請參閱http://stackoverflow.com/questions/7864371/ios-how-to-pass-prepareforsegue-an-object/10858618#10858618 – Macondo2Seattle

回答

1

試試這個:

UITableViewController *secondTableView = (UITableViewController*)[segue destinationViewController]; 

並確保myString應申報財產。

那麼你應該試試這個

secondViewControllwer *secondView = (secondViewControllwer*)[[secondViewControllwer alloc]init]; 

和類的名稱應與資本後者啓動。

+0

不工作,因爲我仍然沒有得到任何參考我的secondViewController 。例如secondViewControllwer * secondView = [secondViewControllwer alloc] init]在這種情況下,我得到一個指向第二類的指針 – user3094099

+0

@ user3094099你說什麼不清除。你的班名是什麼?如果你的課程是'secondViewControllwer',那麼看看我更新的答案。 –

0

您正在訪問UITableViewController上的未定義屬性,而且您無法在標準UITableViewController上聲明自定義屬性,只能使用類別注入方法。我想知道如果UITableViewController是你想爲secondTableView類型?