我有以下简单功能:
class IMGLibraryViewController: UIViewController, PanelContentDelegate {
weak var delegate: IMGPickerDelegate?
@IBAction func fireButton(_ sender: Any) {
let imageSample = UIImage(named: "sample")!
didPickImage(imageDData: imageSample)
}
func didPickImage(imageDData: UIImage) {
delegate?.didFinishPicking(imageDData)
}
然后我对茉莉花进行了以下测试:
class ImageDisplayViewController: UIViewController, IMGPickerDelegate {
@IBOutlet weak var imageDisplayViewOutlet: UIImageView!
var imgLibrary = IMGLibraryViewController()
func didFinishPicking(_ imageData: UIImage) {
imageDisplayViewOutlet.image = imageData
}
override func viewDidLoad() {
super.viewDidLoad()
imgLibrary.delegate = self
}
如下图所示,即使函数返回期望值,测试也将失败!
与返回类型为元组有关吗?还是我做错了其他事情?
在此先感谢您的帮助!