PhotoCollectionViewDelegate具有初始化程序-

-(instancetype)initWithController:(MyViewController *)controller {
    self = [super init];
    if(self) {
        self.myViewController = controller;
    }
    return self;
}

MyViewController.swift文件调用此文件,
let photoCollectionViewDelegate = PhotoCollectionViewDelegate(controller : self)

gives 'Can not convert value of type MyViewController to expected argument type 'MyViewController!'

PhotoCollectionViewDelegate(controller : MyViewController!),但称之为self

最佳答案

这可能很愚蠢,但你有没有试过:
let photoCollectionViewDelegate = PhotoCollectionViewDelegate(controller : self as MyViewController!)

07-24 09:36
查看更多