I am developing an objective c-structure that will be used by other developers.
In this structure I would like to use if available classes from other frameworks, if available.
For example, at the moment I am using AdSupport.framework (if available - associated with the application developer) with the following approach:
if (NSClassFromString(@"ASIdentifierManager")) { NSString adString = [[[NSClassFromString(@"ASIdentifierManager") sharedManager] advertisingIdentifier] UUIDString]; }
However, now I want the arguments of the public functions of my structure to include optional dependency classes, and I cannot do this.
For instance:
I want to have a function:
+ (void) sendLocation: (CLLocation *) myLoc;
but CoreLocation.framework will not necessarily be related and may not be available to the application. How can I follow a similar approach using AdSupport.framework above?
I suggested that I could do something like this:
+ (void) sendLocation: (NSClassFromString(@"CLLocation") *) myLoc;
or
+ (void) sendLocation: (id) myLoc;
or
+ (void) sendLocation: (Class) myLoc;
and then somehow get the coordinates, but could not achieve this. The last option (class) seems to be compiling, but I cannot find a way to extract the parameters ..
Can anyone help with this?
source share