iphone - 在iOS 5中发布UIviewController对象?

标签 iphone ios ipad ios5 ios4

我想在iOS 5中发布UIViewController对象。
在iOS之前的版本(> 5.0)中,我们始终编写代码或维护代码,随后出现内存泄漏的情况,

if(myViewControllerObject != nil){
     [myViewControllerObject.view removeFromSuperView];
     [myViewControllerObject release];
     myViewControllerObject = nil;
} 
 myViewControllerObject = [[MyViewControllerObject alloc] initWithNibName:@"MyViewControllerObject" bundle:nil];
  [self.view addSubview: myViewControllerObject.view];

但是在iOS 5中,我们不能使用 release 方法来释放UIviewController对象,那么我们在iOS 5中需要做什么来维持额外的对象分配和泄漏?
实施此层次结构的最佳方法是什么?

谢谢。

最佳答案

除非您为项目激活自动引用计数,否则您的代码将不会更改为iOS 5。这样一来,由于系统会处理内存管理,因此您将无法使用releasedealloc等。

要了解有关ARC的更多信息,请参见以下问题:How does the new automatic reference counting mechanism work?

关于iphone - 在iOS 5中发布UIviewController对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9701162/

相关文章:

ios - 两分钟gps开启后,为什么设备会停止在iOS上接收位置信息?

iphone - 由于 UIPopoverController,通用 iOS 应用程序在 iPhone/iTouch 3.1.3 上崩溃

objective-c - 如何在 iCarousel 中使用 UIPageControl?

iPhone:UIButton 不使用默认的按下突出显示

iphone - 如何以编程方式隐藏按钮

ios - iOS 中的 Facebook 登录 SDK 语言问题

ios - build设置中的 "Objective-C Bridging Header"条目未出现在 Xcode 8.3 中

ios - NSUserDefaults 中的数据仅在重新运行应用程序后刷新

ios - 如何通过手指获取 UIScrollView 分页?

ios - Apple Watch 是否曾经为重要的位置/访问监控做出过贡献?