Jon*_*gly 2 xcode objective-c uiviewcontroller ios
我有一个名为SurveyQuestion的UIViewController的子类.我为我的应用程序使用了这些数组.我用这一行得到了当前可见的控制器:
SurveyQuestion *currentQuestionController = [self.navigationController visibleViewController];
Run Code Online (Sandbox Code Playgroud)
一切正常,但Xcode给了我一个警告
Incompatible pointer types initializing 'SurveyQuestion *__strong' with an expression of type 'UIViewController *'
Run Code Online (Sandbox Code Playgroud)
我知道这是因为visibleViewController返回一个UIViewController,但它的工作原理是因为SurveyQuestion是一个UIViewController.有没有办法压制这个错误?或者我应该以不同的方式做到这一点?
dan*_*ing 14
你可以像演员一样使用
SurveyQuestion *currentQuestionController = (SurveyQuestion *)[self.navigationController visibleViewController];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3230 次 |
| 最近记录: |