Send Class Name as a argument in iOS


Step 1::   in your current class.

#import “HomeView.h”

#import “MSYCommon.h”

Step 2 ::

*call this from any method of view where MSYCommon is a name of common class.

[MSYCommon pushBackToSpecific:self.navigationController withName:@”HomeView”];

Step 3″:: in MSYCommon class

+(void)pushBackToSpecific:(UINavigationController *)nav withName:(NSString *)screenName{

    Class classFromString = NSClassFromString(screenName);

    for (UIViewController *controller in nav.viewControllers) {

        if ([controller isKindOfClass:[classFromString class]]) {

             [nav popToViewController:controller animated:YES];

            break;

        }

    }

}

 

You Will able to go back to any specific class.

Note:: You can also convert A Class to variable like this

MyClass * variable = [factory makeObjectOfClass:[MyClass class]];


Best Of Luck
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at WordPress.com.

Up ↑

%d bloggers like this: