Closed beltex closed 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).
This has been addressed in #23 with the new error handling in Swift 2.0. See Error Handling section in pull request description.
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.