裏面一個UIViewController的,我執行以下操作:iPhone - NSString的值未設置
TVController* stopTimes = [ [ TVController alloc ] initWithStyle: UITableViewStyleGrouped ];
stopTimes.tableView.frame = CGRectMake(0, 180, 320, 280);
stopTimes.tableView.backgroundColor = [ UIColor whiteColor ];
stopTimes.theID = stopID;
[ self.view addSubview: stopTimes.tableView ];
其中TVController是一個UITableViewController。
在TVController類中,我有一個名爲theID的NSString屬性已被合成。在執行上面的「stopTimes.theID = stopID」時我沒有遇到任何錯誤,並且TableView按預期顯示。在這個TVController類的'viewDidLoad'中,我只是簡單地嘗試NSLog'theID'來表明它的工作,但它是(null),不管我做什麼。
但是,我試圖設置單元格的文本'theID',它工作得很好。
那麼爲什麼'theID'在設置單元格時正確設置,而不是在viewDidLoad中?
你是如何初始化stopID的? – 2009-11-26 06:09:33