Reputation: 2146
I have two classes, Class A and Class B. They can both call the same method in a controller. The method they call takes in a CGPoint
. Is there any way I can determine which class the argument came from?
I have tried using the following:
if ([point isKindOfClass:[_territoryPaths class]])
{
NSMutableDictionary *territoryPaths = [_territoryPaths territoryPaths];
}
if ([piont class] == [_territoryPaths class])
{
NSMutableDictionary *territoryPaths = [_territoryPaths territoryPaths];
}
point
is the CGPoint
that the method takes in.
Upvotes: 0
Views: 99
Reputation: 1085
The best way to deal with this situation if you want to use this method in a class that is not ClassA or ClassB would be to modify your method so that it accepts a sender and do the isKindOfClass on the sender value.
For example:
- (void)someMethod:(id)sender withPoint:(CGPoint)point
{
if ([sender isKindOfClass:[ClassA class]])
{
// Do class A stuff
}
else if ([sender isKindOfClass:[ClassB class]])
{
// Do class B stuff
}
else
{
// Unknown class
}
}
Upvotes: 5