我的一個UIViewController
有幾個子視圖控制器。它們是在界面構建器內部構建的,通過拖動NSObject
到左側的「Objects」部分,然後將我自己的SpecialViewController
作爲「Custom Class」。有了這個設置,在viewDidLoad
我會有我的意見和控制器準備好。工作流是通過下面的截圖提示:正確處理didReceiveMemoryWarning
而且在我的實現,我有:
@interface ParentController : UIViewController
{
SpecialViewController *svc;
}
@property (nonatomic, retain) IBOutlet SpecialViewController *svc;
正如我明白,在我didReceiveMemoryWarning
應該釋放自己的資源。然後在viewDidUnload
期間將IBOutlets
設置爲零。
我得到崩潰在模擬器模擬內存不足的時候,用調試器在SpecialViewController
didReceiveMemoryWarning
(屍體只是[super didReceiveMemoryWarning];
)暫停,錯誤EXC_BAD_ACCESS (code=1, address=0xe0000008)
。此時,父控制器不可見,因此可以安全地釋放。
父控制器在didReceiveMemoryWarning
中也只包含[super didReceiveMemoryWarning];
。我已經在兩個班都嘗試過niling IBOutlets
。它沒有幫助。
任何想法爲什麼發生這種情況?
我使用ARC針對iOS 4 & 5。 SpecialViewController
是UITableViewController
的一個子類。
通過跟蹤,我發現ParentController didReceiveMemoryWarning
在SpecialViewController
之前被調用。
釋放對象並將對象設置爲零不相等。如果你收到記憶警告,你必須釋放**未使用的**資源。先嚐試'[svc release]'。 – Feo
@Feo,嗯......我正在使用ARC。我確實釋放了未使用的資源。那些是我在我自己的班級中管理的,對嗎? –
你在做'self.scv = nil'嗎? – Peres