PerformSelector警告 [英] PerformSelector warning

查看:156
本文介绍了PerformSelector警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到警告


PerformSelector可能导致泄漏,因为其选择器未知

PerformSelector may cause a leak because its selector is unknown

代码:

- (void) callDelegate: (SEL) selector withArg: (id) arg error: (NSError*) err
{
    assert([NSThread isMainThread]);
    if([delegate respondsToSelector: selector])
    {
        if(arg != NULL)
        {
            //this line the warning
            [delegate performSelector: selector 
                           withObject: arg 
                           withObject: err]; 
        }
        else
        {
            //this line the warning
            [delegate performSelector: selector 
                           withObject: err]; 
        }
    }
    else
    {
        NSLog(@"Missed Method");
    }
}

标题:

@interface Topscore : UIViewController <NSObject> {

//
}


推荐答案

这是编译器生成的警告,因为在启用编译和自动引用计数(ARC)时使用了-Wundeclared-selector。通常,这可以安全地忽略,因为显然名为selector的变量中的选择器在编译时是未知的,因为它将在运行时分配其值。

This is a warning generated by the compiler because -Wundeclared-selector was used while compiling and automatic reference counting (ARC) is enabled. This can be, in general, safely ignored, as it's obvious that the selector in the variable named "selector" is unknown at compile time, as it will have its value assigned at runtime.

这篇关于PerformSelector警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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