2016-09-10 62 views
1

我知道這個問題,許多開發人員問這麼多時間,但我已檢查所有答案,並在我的代碼中實現,但仍造成內存泄漏NSStringNSString的內存泄漏與ARC啓用項目

這裏是我的代碼:

_lblTotalOutFlowTitle.text = (APPDELEGATE.isAllSelectFilter ? APPDELEGATE.strKeyOutflow_TotalLive1 :APPDELEGATE.strKeyOutflow_Total); 

內存泄漏: enter image description here

了我所要解決此泄漏:

1:

_lblPopulationTitle.text = [(APPDELEGATE.isAllSelectFilter ? APPDELEGATE.strKeyPopulationLive1 : APPDELEGATE.strKeyPopulation) copy]; 

第二:

NSString *strPopulationLive1 = [(APPDELEGATE.isAllSelectFilter ? APPDELEGATE.strKeyPopulationLive1 : APPDELEGATE.strKeyPopulation) copy]; 
     _lblPopulationTitle.text = strPopulationLive1; 

第三:

_lblPopulationTitle.text = [NSString stringWithFormat:@"%@",(APPDELEGATE.isAllSelectFilter ? APPDELEGATE.strKeyPopulationLive1 : APPDELEGATE.strKeyPopulation)]; 

APPDELEGATE.strKeyPopulation是具有低於屬性字符串對象。

@property (nonatomic, strong) NSString *strKeyPopulation; 

任何想法如何解決此泄漏。

在此先感謝。

+0

爲什麼要在第二點製作副本。刪除副本,並嘗試如果它的工作。 – Bhupesh

+0

不,這也將無法正常工作,我已經嘗試過,但沒有複製,但仍然泄漏內存。 – CodeChanger

回答

-1

更改strong改爲copy

試試

祝願

+0

這一個是不允許它的我的主要字符串,並沒有創建它作爲複製類型屬性。謝謝。 – CodeChanger

+0

爲什麼不允許? –

+1

你的回答對於用戶在現有方法中闡述你的方法和問題是沒有幫助的 – Abhijeet