簡體   English   中英

對視圖屬性的引用保留了視圖控制器

[英]reference to view property is retaining the view controller

使用視圖控制器的視圖時出現內存泄漏我的代碼序列如下

 viewController1 = [[ViewController alloc] init];
   destinationViewController = [[DestinationViewController alloc] init];
   [destinationViewCOntroller useView:viewController1.view];
   [viewController1 release];
   [destinationViewController release];

出於測試目的,我在useView方法中使用了空的實現。 所以我的問題是viewController1永遠不會被釋放。 我確保沒有其他地方對viewController1有任何引用。 當我刪除傳遞給viewcontroller1.view的方法call(useView)時,那么viewcontroller1正在正確地分配。 任何想法為什么會這樣?

這似乎是一個相當學術性的問題。 只需啟用ARC,然后就不用管它了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM