to prevent warning from "PerformSelect may cause a leak because its selector is unknown"
22,482
Just use this:
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self performSelector:sel withObject:arguments];
#pragma clang diagnostic pop
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on May 30, 2020Comments
-
Admin about 4 years
Possible Duplicate:
performSelector may cause a leak because its selector is unknownI 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 :)