Can't figure out what's wrong.
struct Ring_Sensors_Input_struct
{
var ts: Double
var temp: UInt16
var hr: UInt8
var spO2: UInt8
var rr: UInt8
var steps: UInt16
init( ts: Double,
temp: UInt16,
hr: UInt8,
spO2: UInt8,
rr: UInt8,
steps: UInt16 )
{
self.ts = ts
self.temp = temp
self.hr = hr
self.spO2 = spO2
self.rr = rr
self.steps = steps
}
}
func my_func()
{
var ring_sensors_input: [Ring_Sensors_Input_struct] = []
ring_sensors_input.append( ts: 1657150485.0, temp: 235, hr: 95, spO2: 97, rr: 16, steps: 235 ) <<<<<<<<< ERROR: No exact matches in call to instance method 'append'
ring_sensors_input.append( ts: 1657150486.0, temp: 238, hr: 92, spO2: 98, rr: 14, steps: 238 ) <<<<<<<<< ERROR: No exact matches in call to instance method 'append'
}
CodePudding user response:
Just replace your code by:
func my_func() {
var ring_sensors_input: [Ring_Sensors_Input_struct] = []
ring_sensors_input.append(Ring_Sensors_Input_struct(ts:1657150485.0, temp: 235, hr: 95, spO2: 97, rr: 16, steps: 235))
ring_sensors_input.append(Ring_Sensors_Input_struct(ts: 1657150486.0, temp: 238, hr: 92, spO2: 98, rr: 14, steps: 238))
}
The problem is if you want to append an object, like your structure, you have to call it inside the append method. If you don't, the code doesn't know what you are trying to add.