Home > Objective C > Selectors with multiple arguments

Selectors with multiple arguments

I’ve needed to figure out if a certain function exists for a class before instantiating a new class. However the init function takes two parameters and all code samples I’ve seen use selectors with just a single parameter. Below is the code that checks if a selector with two parameters is present.

if([NSClassFromString(classType) instancesRespondToSelector: @selector(initWithTwoParameters: withSecondParameter:)])
{
}
Categories: Objective C Tags:
  1. No comments yet.
  1. No trackbacks yet.