relatively new programmer here. Look a开发者_JS百科t the two classes defined below. I'd like to be able to call the following:
[instanceOfSecondClass transitionToPage: [instanceOfFirstClass nextPage]];
However, that doesn't seem to work (because I'm trying to return a class, not an instance of a class.)
@implementation FirstClass
- (id)nextPage {
return SomeOtherClass;
}
@end
@implementation SecondClass
- (void)transitionToPage:(id)someOtherClass {
currentPageViewController = [[mySomeOtherClass alloc] init];
...
}
@end
Is there any way to accomplish what I am trying to do here?
Sometimes things that make sense to me totally don't make sense in the real world :).
Thanks for the help!
"Class" is the type you want to return
@implementation MyClass
- (Class)nextPage {
return [SomeOtherClass class];
}
@end
Hope it works, ief2
精彩评论