Saturday, December 7, 2013

How do I know the class name to instantiate an object?

For example: class inherits UIViewController
LabelUserViewController
I get to the string: LabelUserViewController
Whether it can instantiate an object based on the string name? Find Daren ~ ~ ~
Reply:
Daren ~ ~ Help? ?
Reply:
Never seen so instantiate viewController's. Why is there such a demand for it. You should re-design the next.
Reply:
You are similar to the effect of it, (@ "MyClassName") to do with NSClassFromString, such as:

 
id viewController = [[NSClassFromString (cell.detailViewController) alloc] initWithStyle: UITableViewStyleGrouped];
[Self.navigationController pushViewController: viewController animated: YES];


Reply:
reference to the third floor of the reply:
you is similar to the effect of it, (@ "MyClassName") to do with NSClassFromString, such as:

C / C + + code

id viewController = [[NSClassFromString (cell.detailViewController) alloc] initWithStyle: UITableViewStyleGrouped];
[Self.nav ......


Positive solutions ~ ~ ~ thankX

No comments:

Post a Comment