An Objective-C Finite-state machine