Closed dducro closed 9 years ago
Hi @dducro!
You have to call the open()
method first to get a connection to the SMC driver (and make sure to call close()
when your done!)
Here's a simple example:
import IOKit
var smc = SMC()
if smc.open() != kIOReturnSuccess {
println("ERROR: Failed to open connection to SMC")
} else {
let temperatureSensors = smc.getAllValidTemperatureKeys()
for key in temperatureSensors {
let temperatureSensorName = SMC.Temperature.allValues[key]!
let temperature = smc.getTemperature(key).tmp
println("\(temperatureSensorName): \(temperature)°C")
}
smc.close()
}
Take a look at the SMCKitTool source for more detail. Hope that helps!
Awesome! Thanks for the example!
Hey,
I imported SMC.swift in my project. However I can't get it to print the current Temperature values. The following prints an empty array and 0.0 for every Temperature sensor. Am I missing something?