当没有替代方法时,禁止对已弃用方法发出警告 [英] Suppress warning for deprecated method when there's no alternative for it

查看:28
本文介绍了当没有替代方法时,禁止对已弃用方法发出警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个项目中实现了这个自定义类:https://github.com/wimagguc/ios-custom-alertview

I've implemented this custom class in a project: https://github.com/wimagguc/ios-custom-alertview

但 Xcode 发出警告,指出initWithParentView"已被弃用.

But Xcode gives a warning that the "initWithParentView" has been deprecated.

- (id)init
{
    return [self initWithParentView:NULL];
}

我一直找不到这种方法的替代方法,而且这门课的效果非常好.有人可以告诉我如何抑制此警告或告诉我initWithParentView"的替代方法吗?

I haven't been able to find a alternative to this method, and the class works splendid. Can someone tell me how to suppress this warning OR tell me an alternative to "initWithParentView"?

推荐答案

请阅读更改说明,里面明确说使用 init 方法

please read the change notes it clearly says use init method

当它进入无限循环时使用 [super init] 而不是 [self init]

as it's going in the infinite loop use [super init] instead of [self init]

- (id)init
{
   // return [self init]; 
      return [super init];
}

这篇关于当没有替代方法时,禁止对已弃用方法发出警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆