Finite State Machines (FSM) and Pushdown Automata (PDA), modelled with Objective-C, using the GOF's State Design pattern.
Initially developed for a project in a graduate Distributed Systems course, later refined in a graduate Design Patterns course. Since then I've used this in commercial projects.
Better documentation will be provided as time allows, for now, here is a brief description of what you'll find here.
This code requires ARC and is known to work with iOS 5.x and later in Xcode 4.5 and later.
An object that has a current FSM state.
A state in a FSM. <RCSState>
objects are intended to be stateless, shared objects - flyweights.
Define methods on your state objects that transition its <RCSStateContext>
to another state.
Default implementation of the <RCSState>
protocol.
An object that has a current PDA state.
A state in a PDA. This is useful when you multiple states need to be able to transition to a single state, and that state needs to be able to "go back" to whichever one transitioned to it. Rather than having a combinatorial explosion in the number of states to facilitate this, things stay simple by pushing the common state and defining a transition that pops back.
Define methods on your pushdown state objects that transition and push its to another pushdown state.
Default implementation of the <RCSPushdownState>
protocol.
Respresents a task that uses a FSM to coordinate itself - an alternative to NSOperation
that you can use to model a complex multi-state process. This is provided an example, but it is quite useful and was written for a production iOS app.
FSM states for a RCSTask
.
##RCSTaskQueue <RCSStateContext, RCSTaskDelegate>
Represents a queue that undestands the semantics of RCSTask
- a lightweight alternative to NSOperationQueue
.
FSM states for a RCSTaskQueue
.