2016-09-10 34 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