2012-08-06 32 views
2

我有一个名为SurveyQuestion的UIViewController的子类。我使用这些数组为我的应用程序。我得到这一行当前可见的控制器:抑制UIViewController的子类的Xcode不兼容指针类型

SurveyQuestion *currentQuestionController = [self.navigationController visibleViewController]; 

一切正常,但Xcode中给我的

Incompatible pointer types initializing 'SurveyQuestion *__strong' with an expression of type 'UIViewController *' 

警告我知道这是因为visibleViewController返回一个UIViewController,但它的作品,因为SurveyQuestion IS一个UIViewController。有什么办法来压制这个错误?或者我应该以不同的方式去做?

回答

13

您可以使用像投

SurveyQuestion *currentQuestionController = (SurveyQuestion *)[self.navigationController visibleViewController]; 
+0

咄,我肯定是要仔细考虑 – 2012-08-06 18:05:08