views:

47

answers:

1

Hi - relatively new programmer here. Look at 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!

+6  A: 

"Class" is the type you want to return

@implementation MyClass
- (Class)nextPage {
     return [SomeOtherClass class];
}
@end

Hope it works, ief2

Ief2
Excellent! I knew it was possible, I just couldn't quite figure out the syntax.
Jake Zerrer