编译时遇到错误:
var beaconIDs = [BeaconID]()
for i in 0..<BeaconsStruct.uuidT.count {
beaconIDs.append(BeaconID(UUIDString: BeaconsStruct.uuidT[i], major:
Int(BeaconsStruct.majorT[i])!, minor: Int(BeaconsStruct.minorT[i])!))
}
错误是:无法推断通用参数“元素”。
BeaconID包含:
struct BeaconID: Equatable, CustomStringConvertible, Hashable {
let proximityUUID: UUID
let major: CLBeaconMajorValue
let minor: CLBeaconMinorValue
init(proximityUUID: UUID, major: CLBeaconMajorValue, minor: CLBeaconMinorValue) {
self.proximityUUID = proximityUUID
self.major = major
self.minor = minor
}
init(UUIDString: String, major: CLBeaconMajorValue, minor: CLBeaconMinorValue) {
self.init(proximityUUID: UUID(uuidString: UUIDString)!, major: major, minor: minor)
}
}
BeaconsStruct包含:
struct BeaconsStruct {
static var uuidT: [String] = []
static var minorT: [String] = []
static var majorT: [String] = []
static var lokalizacjaT: [String] = []
}
我可以请你帮忙吗?
答案 0 :(得分:0)
major
和minor
的演员表错了。初始值设定项需要CLBeaconMajorValue
和CLBeaconMinorValue
,因此转换为Int
而不是转换为var beaconIDs = [BeaconID]()
for i in 0..<BeaconsStruct.uuidT.count {
beaconIDs.append(BeaconID(UUIDString: BeaconsStruct.uuidT[i],
major: CLBeaconMajorValue(BeaconsStruct.majorT[i])!,
minor: CLBeaconMinorValue(BeaconsStruct.minorT[i])!))
}
。
data-grunticon-embed