是否有可能在Objective-C中返回一个类(但不是类的实例)?

Jak*_*rer 0 cocoa objective-c

相对较新的程序员在这里.看看下面定义的两个类.我希望能够打电话给以下人员:

[instanceOfSecondClass transitionToPage: [instanceOfFirstClass nextPage]];
Run Code Online (Sandbox Code Playgroud)

但是,这似乎不起作用(因为我试图返回一个类,而不是一个类的实例.)

@implementation FirstClass
- (id)nextPage {
    return SomeOtherClass;
}
@end


@implementation SecondClass
- (void)transitionToPage:(id)someOtherClass {
    currentPageViewController = [[mySomeOtherClass alloc] init];
    ...
}
@end
Run Code Online (Sandbox Code Playgroud)

有没有办法完成我想在这里做的事情?

有时对我来说有意义的事情在现实世界中完全没有意义:).

谢谢您的帮助!

v1A*_*xvw 7

"类"是您想要返回的类型

@implementation MyClass
- (Class)nextPage {
     return [SomeOtherClass class];
}
@end
Run Code Online (Sandbox Code Playgroud)

希望它有效,ief2