1

I'm using this function:

- (NSUInteger)indexOfViewController:(UIViewController *)viewController
{
    return viewController.ident; // this doesn't work: property 'ident' not found
}

In this function there are getting passed viewControllers from different types so: vc1, vc2, vc3, vc4, ... and they all have a 'ident' property and inherit from UIViewController. How can I access this property?

4

2 回答 2

1

You need to cast the viewController to the Class which has the ident property. Or do it by using valueForKey like this:

- (NSUInteger)indexOfViewController:(UIViewController *)viewController
{
    return [[viewController valueForKey:@"ident"] integerValue]; 
}
于 2013-04-29T12:21:08.143 回答
-1

You can try this line of code:

return [viewController performSelector:@selector(ident)];

于 2013-04-29T12:20:24.170 回答