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
是 MyViewController
。
最佳答案
这可能很愚蠢,但你试过吗:
let photoCollectionViewDelegate = PhotoCollectionViewDelegate(controller : self as MyViewController!)
关于ios - 将未包装的引用传递给 Objective C 初始值设定项的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43366252/