
例如做类似的事情:
//in .h file@interface CustomVIEw : UIVIEw{ UIVIEw *currentVIEw;}// in .m file:-(voID)createVIEw1{ currentVIEw = [[UIVIEw alloc] init]; [self addSubvIEw:currentVIEw];}-(voID)createVIEw2{ [currentVIEw removeFromSupervIEw]; // does the former vIEw get released by arc // or does this leak? currentVIEw = [[UIVIEw alloc] init]; [self addSubvIEw:currentVIEw];} 如果此代码泄漏,我将如何正确声明* currentVIEw?或者我如何让ARC“释放”当前视图?谢谢!
解决方法 使用ARC,您无需考虑发布/保留.由于您的变量将被隐式定义为strong,因此无需将其设置为NulL – 它将在分配之前释放.
我个人虽然喜欢声明属性:
@property (strong,nonatomic) UIVIEw *currentVIEw;@H_404_0@ 总结
以上是内存溢出为你收集整理的ios – 如果我将指针设置为nil,自动引用计数是否会释放一个对象?全部内容,希望文章能够帮你解决ios – 如果我将指针设置为nil,自动引用计数是否会释放一个对象?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)