我到处都在寻找解决方案,但是我不知道为什么这不起作用`
listing.termContracts.forEach {
cell.segmentedControl.insertSegment(withTitle: $0.availableFor, at: cell.segmentedControl.numberOfSegments)
}
它返回一个奇怪的错误:无法使用类型为'(withTitle:String,at:Int)'的参数列表调用'insertSegment'
这毫无意义,因为我传递了正确的数据类型。 termContracts结构类似于以下内容:
import UIKit
struct TermContract {
var availableFor: String
var availableYear: String
var sharedPrivate: String
var spacesAvailable: Int
var rent: Int
var deposit: Int
var averageUtilities: Int?
init(_ dict: [String: Any]) {
self.availableFor = dict["availableFor"] as? String ?? ""
self.availableYear = dict["availableYear"] as? String ?? ""
self.sharedPrivate = dict["sharedPrivate"] as? String ?? ""
self.spacesAvailable = dict["spacesAvailable"] as? Int ?? 0
self.rent = dict["rent"] as? Int ?? 0
self.deposit = dict["deposit"] as? Int ?? 0
self.averageUtilities = dict["averageUtilities"] as? Int
}
}
这是小故障吗?