iOS: perform performSelector using nsstring : performSelector may cause a leak because its selector is unknown [duplicate]

StackOverflow https://stackoverflow.com/questions/20677426

문제

I'm trying to perform performSelector selecting methods from nsarray but I'm getting this error:

performSelector may cause a leak beacause its selector is unknown

Here is my code:

-(void)exceudeMethods
{
    NSArray *methods = @[@"methodOne",@"methodTwo"];

    for (int i =0 ; i < methods.count; i++)
    {
       [self performSelector:NSSelectorFromString([NSString stringWithFormat:@"%@:",methods[i]])];

    }

}

if I replace any of you know how can I fix this so I can execute all the methods in the nsarray?

도움이 되었습니까?

해결책

strange that the warning is removed if you replace the line with

    [self  performSelector:NSSelectorFromString(methods[i]) withObject:nil afterDelay:0.0f];

seems to work.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top