Download User manual

Transcript
12. Using Yocto-Volt with Objective-C
line of code. You simply need to call the yDisableExceptions() function to commute the library
to a mode where exceptions for all the functions are systematically replaced by specific return
values, which can be tested by the caller when necessary. For each function, the name of each
return value in case of error is systematically documented in the library reference. The name always
follows the same logic: a get_state() method returns a Y_STATE_INVALID value, a
get_currentValue method returns a Y_CURRENTVALUE_INVALID value, and so on. In any
case, the returned value is of the expected type and is not a null pointer which would risk crashing
your program. At worst, if you display the value without testing it, it will be outside the expected
bounds for the returned value. In the case of functions which do not normally return information, the
return value is YAPI_SUCCESS if everything went well, and a different error code in case of failure.
When you work without exceptions, you can obtain an error code and an error message explaining
the source of the error. You can request them from the object which returned the error, calling the
errType() and errMessage() methods. Their returned values contain the same information as
in the exceptions when they are active.
62
www.yoctopuce.com