无法调用' ...'使用类型' ...'的参数列表

时间:2015-06-16 21:26:25

标签: ios swift

这一行:

appDelegate.navigationController.pushViewControllerOnTopOfEverything(controller)

导致此错误:

Cannot invoke 'pushViewControllerOnTopOfEverything' with an argument list of type '(VUPickerController!)'

这里有完整的功能:

    func onSortTapped() {

    if self.pickerModel == nil {
        self.pickerModel = VUPickerModel.newOrExistingPickerModelForKey(VUPickerModelKeyType.ShowsSort)
    }

    var controller = VUPickerController(model: self.pickerModel) { (selectionChanged) in

        if selectionChanged {
            self.pickerModel?.archiveWithModelKeyType(VUPickerModelKeyType.ShowsSort)

            let userSelections = self.pickerModel!.selectedRows()
            let sectionItem = userSelections![0] as! VUPickerSectionItem
            self.leftGenreBar?.genreName = sectionItem.title
        }
    }

    let appDelegate = UIApplication.sharedApplication().delegate
    appDelegate.navigationController.pushViewControllerOnTopOfEverything(controller)

}

navigationController是用Obj-C编写的自定义UIViewControllerpushViewControllerOnTopOfEverything定义为:

- (void)pushViewControllerOnTopOfEverything:(UIViewController *)viewController;

此外,VUPickerControllerUIViewController的子类。

onSortTapped()最初是用Obj-C编写的,我试图做一个简单的翻译,但我错过了一些东西。

我确实尝试投射到UIViewController

appDelegate.navigationController.pushViewControllerOnTopOfEverything(controller as! UIViewController)

但得到了类似的错误:

Cannot invoke 'pushViewControllerOnTopOfEverything' with an argument list of type '(UIViewController)'

修改

当我尝试:

po appDelegate.navigationController
我得到调试控制台中的

error: <EXPR>:1:13: error: type of expression is ambiguous without more context

如果我只是po:

po appDelegate

我明白了:

Printing description of appDelegate:
Optional(<AppDelegate: 0x7f81a2d1cc40>)

navigationController是appDelegate的一个属性,在原始的Obj-C appDelegate.h文件中声明。

0 个答案:

没有答案