【问题标题】:Viewcontroller deallocating my objectViewcontroller 释放我的对象
【发布时间】:2014-01-06 07:50:57
【问题描述】:

我正在加载一个崩溃的 viewController (LandingViewController),因为 UIKit 出于某种原因正在释放我的“ConnectionStatus”对象,我正在尝试向它发送消息。

我的代码如下:

@property (nonatomic, strong) ConnectionStatus *cStatus;

- (void)viewDidLoad
{
    [super viewDidLoad];
    ...
    self.cStatus = [[ConnectionStatus alloc] init];
}

当我加载僵尸乐器时,我得到了这个:

UIKit 在我的视图控制器加载之前释放对象有什么原因吗?

更新(我如何加载这个视图控制器):

-(void)logout {
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
    LandingViewController *lvc = [storyboard instantiateViewControllerWithIdentifier:@"landingVC"];

    [self presentViewController:lvc animated:YES completion:nil];
}

【问题讨论】:

  • 登录按钮?有这个方法吗,如果有请分享一下
  • 让我在没有登录按钮的情况下更新代码...恐怕会误导...
  • LandingViewController 好像被释放了,所以 cStatus 也被释放了。
  • 你的 loginButton 正在释放你的 viewController 我不知道为什么
  • 登录按钮代码基本上是调用cStatus.isHostReachable方法。我已经删除了那个电话,并更新了上面的图片。

标签: ios objective-c


【解决方案1】:

viewDidLoad 发布是正确的;即 ARC 释放您创建并分配给 strong 属性的对象。

问题似乎出在您的 ProfileViewController 或正在发送的任何通知中。在您发布通知的地方,该对象是一个僵尸。您可能错误地保留了某些内容或将其(或拥有的对象)用作通知对象,但我们需要查看该代码才能确定。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-15
    • 1970-01-01
    相关资源
    最近更新 更多