Search code examples
iosios6uistoryboardsegueuistoryboardsegue

How to determine the Destination View Controller class correctly


I am trying to check the class of the destination view controller correctly, but cannot figure how to do this.

I have tried the following:

if (segue.destinationViewController == NSStringFromClass([MESSelectWordViewController class])) {

But this does not work as expected, it does not result correctly. MESSelectWordViewController is my view controller class that I am passing information to within prepareForSegue method. However, I only need this information to be passed on this specific segue as opposed to any others. Therefore I am doing the above if to pass the information if correct.

What is the correct way to accomplish this, surely there is a better route as opposed to NSString@"MESSelectWordViewController ?


Solution

  • Try:

     if ([segue.destinationViewController isKindOfClass:[MESSelectWordViewController class]]) {