2012-04-01 37 views
0

我正在使用標籤欄應用程序的情節提要。在其中一個選項卡中,我製作了一個tableView。數據填充好。當我嘗試導航到同一個選項卡中的另一個UITableViewController時,存在這個問題。- [國家保留]:發送到釋放實例的消息0x6829280

Countries.h(類故事板被召)

@property(nonatomic,retain)NSMutableArray *items; 
@property(nonatomic,retain)Country *country; 
@property(nonatomic)int continentID; 

方法:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    self.continent=[self.items objectAtIndex:[indexPath row]]; 

    Countries *detailViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"theCountries"]; 
detailViewController.continentID=self.continent.continentID; 
detailViewController.title=self.continent.continentName; 
[self.navigationController pushViewController:detailViewController animated:YES]; 
[detailViewController release]; 
} 

在瀏覽我越來越 - [國家保留]:消息發送到釋放實例0x6829280。不self.storyboard instantiateViewControllerWithIdentifier:@「theCountries」分配實例?它出什麼問題了?

回答

2

您正在過度釋放您的detailViewController對象。

順便說一下,靜態分析器會發現這個錯誤。

+0

我評論[detailsViewController發佈],得到了終止應用程序由於未捕獲的異常「NSInvalidArgumentException」,原因是:「 - [洲setContinent:]:無法識別的選擇發送到實例0x6b67f80」 ***第一擲調用堆棧: (0x159a022 0x172bcd6 0x159bcbd 0x1500ed0 0x1500cb2 0x387c 0x16c5c5 0x16c7fa 0xa0185d 0x156e936 0x156e3d7 0x14d1790 0x14d0d84 0x14d0c9b 0x14837d8 0x148388a 0xdb626 0x2342 0x22b5) 終止叫做拋出異常 – NCFUSN 2012-04-01 15:51:42

+0

PS我沒有使用ARC – NCFUSN 2012-04-01 15:52:02

+0

聽起來像是你沒有執行'-setContinent:'非常多。順便說一句,只有名稱以「new」,「init」或「copy」開頭的方法應該(並且在蘋果框架中)返回保留的對象。 – Ahti 2012-04-01 15:55:12

相關問題