【问题标题】:[alertsuccess release]; xcode 4.2[警报成功发布];代码 4.2
【发布时间】:2011-11-10 09:00:09
【问题描述】:

我在 Xcode 4.2 中遇到 [alertsuccess release] 错误。它表示该版本不可用且在自动引用计数模式下不可用,并且 ARC 禁止显式发送发布消息。

我的应用程序和代码在 Xcode 4.1 中运行。怎么了?

    if([serverOutput isEqualToString:@"Yes"]){


    UIAlertView *alertsuccess = [[UIAlertView alloc] initWithTitle:@"Congrats" message:@"You are authorized "
                                                          delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

    [alertsuccess show];
    [alertsuccess release];




} else {
    UIAlertView *alertsuccess = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Username or Password Incorrect"
                                                          delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
    [alertsuccess show];
    [alertsuccess release];

}

【问题讨论】:

标签: xcode4.2


【解决方案1】:

使用自动引用计数,您不再需要自己保留和释放对象。

您可以在项目的构建设置中禁用 ARC,也可以删除对 -release 的调用。

【讨论】:

    猜你喜欢
    • 2023-02-02
    • 2013-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-11
    相关资源
    最近更新 更多