gpt4 book ai didi

ios - UITableView 单元的单元测试。访问单元的 Nib

转载 作者:行者123 更新时间:2023-11-30 13:21:53 25 4
gpt4 key购买 nike

我尝试测试我的 TableView 单元格是否获得正确的值。该单元是定制的并且有自己的 xib 文件。

self.organizationController?.organizationsTableView.registerNib(UINib.init(nibName:String(OrganizationTableViewCell), bundle: nil), forCellReuseIdentifier: String(OrganizationTableViewCell))
let organizationName = "Name"
let organization = Organization.organizationWithName(organizationName, index: 0)
self.organizationController?.organizations = [organization]
let cell = self.organizationController?.organizationsTableView.cellForRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 0)) as! OrganizationTableViewCell
XCTAssertEqual(cell.organizationNameLabel.text, organizationName, "Cell created properly")

使用此代码,我收到错误:无法将“myApplication.OrganizationTableViewCell”类型的值转换为“myApplicationTests.OrganizationTableViewCell”

当我将 xib 文件中的模块更改为 myApplicationTests 时,它开始对测试用例正常工作,但不适用于通常的应用程序运行。我该如何处理这个问题?

最佳答案

您可能在几个月前解决了这个问题,但听起来您只需要更改 Nib 的目标成员资格以包含 myApplicationTests 或在测试文件的顶部导入 myApplication。

关于ios - UITableView 单元的单元测试。访问单元的 Nib ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37696634/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com