我知道这个问题,许多开发人员问这么多时间,但我已检查所有答案,并在我的代码中实现,但仍造成内存泄漏在NSString
。NSString的内存泄漏与ARC启用项目
这里是我的代码:
_lblTotalOutFlowTitle.text = (APPDELEGATE.isAllSelectFilter ? APPDELEGATE.strKeyOutflow_TotalLive1 :APPDELEGATE.strKeyOutflow_Total);
了我所要解决此泄漏:
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;
任何想法如何解决此泄漏。
在此先感谢。
为什么要在第二点制作副本。删除副本,并尝试如果它的工作。 – Bhupesh
不,这也将无法正常工作,我已经尝试过,但没有复制,但仍然泄漏内存。 – CodeChanger