So, there are other postings on how to get rid of this warning, but none seem to work on a SEL parameter -- so this is not a duplicate.
So, I'm creating a printer interface, and in the interest of modularity I created a method to which you provide a callback, as shown below.
This works great, my printer class does not seem to need to know about my client UI class, except, i get the subject warning "PerformSelector may cause a leak because its selector is unknown".
I know there are other ways to get callback action (eg a delegate), but is there a way to use this pattern (callback as method parameter) and not cause this warning?
Thanks!
* IN MY PRINTER CLASS *
+(void) SearchPrinters:(id)onfinish_callback_target withSelector: (SEL)onfinish_callback_sel
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// perform the search
dispatch_sync(dispatch_get_main_queue(), ^{
[onfinish_callback_target performSelector:onfinish_callback_sel]; // <-- WARNING HERE
});
});
}
* IN MY CLIENT UI CLASS *
-(void) OnTouch_Search
{
// pushed button, prepare for search and call
[cPrinterInterface SearchPrinters:self withSelector:@selector(SearchCallback)];
}
-(void) SearchCallback
{
// do stuff when done
}