beltex / SMCKit

Apple SMC library & tool
https://beltex.github.io/SMCKit
MIT License
473 stars 55 forks source link

Removal of tuple return - I/O Kit & SMC return codes #8

Closed beltex closed 9 years ago

beltex commented 9 years ago
... -> (..., IOReturn: kern_return_t, kSMC: UInt8)

Do we really need to return the error codes? On a debug build, they'll be printed out. In release, could you/would you act on those error codes? Probably not. The value returned should indicate if something has gone wrong already, like 0 RPM for a fan speed call.

beltex commented 9 years ago

In addition to this, another thing to ponder is if to return optional values instead. This would be more Swifty in approach and probably better. For main values (like say fan RPM), nil makes it clear that something has gone wrong, while for error codes, nil would indicate no error (as seen in NSJSONSerialization for example).

beltex commented 9 years ago

Related: https://github.com/beltex/SystemKit/issues/17

beltex commented 9 years ago

This has been addressed in #23 with the new error handling in Swift 2.0. See Error Handling section in pull request description.