Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

to prevent warning from "PerformSelect may cause a leak because its selector is unknown" [duplicate]

Possible Duplicate:
performSelector may cause a leak because its selector is unknown

I did a NSDictionary to convert my input(NSString) to selector. The "selector map" is looked as follows :

[self setCmdSelectorMap:[NSDictionary dictionaryWithObjectsAndKeys:                           [NSValue valueWithPointer:@selector(doOpenBrowserByString:)], @"openBrowser",                          [NSValue valueWithPointer:@selector(syncData:)], @"sync",                          [NSValue valueWithPointer:@selector(getCachedString:)], @"getCachedString",                          nil]]; 

When I try to fetch one of these selector and perform it by follows, it cause a warning :

sel = [[_cmdMap objectForKey:command] pointerValue]; NSLog(@"selector determined : %@", NSStringFromSelector(sel)); [self performSelector:sel withObject:arguments]; 

The warning says : PerformSelector may cause a leak because its selector is unknown. Is there any way to prevent this warning from occurring? or is there any "safer" way to perform such an action?

Thanks guys :)

like image 865
Rayer Avatar asked May 29 '12 04:05

Rayer


1 Answers

Just use this:

#pragma clang diagnostic push #pragma clang diagnostic ignored "-Warc-performSelector-leaks" [self performSelector:sel withObject:arguments]; #pragma clang diagnostic pop 
like image 154
Alexander Zakatnov Avatar answered Oct 05 '22 09:10

Alexander Zakatnov