I have a different point of vue, i dont think that using :
Code:
if ([myDelegate isKindOfClass:[UIViewController class]]){
//take appropriate steps
} else if ([myDelegate isKindOfClass:[WeirdCustomObject class]]){
//take appropriate steps
}
is the appropriate method... Delegation is made to avoid that. (What if you rename, add or remove a controller ? you will have to edit your view, which is the opposite of the separation of concern principle : your component should not need to know which controller implement it.
Imagine that the UITableView component was supposed to check which controller is calling it to know what to do : each time you create a new app you would have to edit the UITableView code, it would be absurd)
You have to declare a protocol in your view; any controller which needs to receive messages from your view will set itself as delegate of your view,
and when when you need to display a modal view, call your delegate.
In your view you have :
Code:
if(somethingHappened) {
[delegate presentModalView];
}
Then in each different controller you will have :
in the set up :
Code:
theView.delegate = self;
and the protocol implementation :
Code:
-(void) presentModalView {
//present the appropriate modal view according to the controller
}
Your view should never directly present a modal view controller, it's the controller job.
The view is only here to display stuff and send message when user do something.
Vincent.