@@ -7,7 +7,7 @@ for clarity and maintainability. Can create diagrams:
77![ example digraph] ( example-digraph.png )
88
99- Version 0.1.0 (following [ Semantic Versioning] [ ] )
10- - Developed and tested under Xcode 6.3β4 (Swift 1.2 )
10+ - Developed and tested under Swift 1.2 (Xcode 6.3 )
1111- Published under the [ MIT License] ( LICENSE )
1212- [ Carthage] [ ] compatible
1313
@@ -31,12 +31,12 @@ Features
3131--------
3232
3333- Diagrams that can be automatically saved in your repo each time you run
34- the app in a simulator
34+ the app in the simulator
3535- Immutable, reusable state machine schemas
3636- Readable state and event names — no long prefixes
37- - Type safety: compile time errors when forgetting about a state or an
38- event when defining the schema, when passing an event from a different
39- state machine, etc.
37+ - Type safety: errors will appear at compilation when a state or an event
38+ are absent from schema, when passing an event from a different state
39+ machine, etc.
4040
4141
4242Documentation
@@ -61,7 +61,7 @@ project. We recommend using [Carthage][Carthage add]:
6161Example
6262-------
6363
64- In this example we're going to implement a simple state machine you've
64+ In this example, we're going to implement a simple state machine you've
6565seen at the beginning of this file:
6666
6767![ example digraph] ( example-digraph.png )
@@ -78,14 +78,14 @@ enum Operation {
7878}
7979```
8080
81- Next we have to specify the state machine layout. In SwiftyStateMachine
82- it means creating a schema. Schemas are immutable ` struct ` s that can be
81+ Next, we have to specify the state machine layout. In SwiftyStateMachine,
82+ that means creating a schema. Schemas are immutable ` struct ` s that can be
8383used by many ` StateMachine ` instances. They indicate the initial state
84- and describe transition logic — how states are connected via events and
84+ and describe transition logic, i.e. how states are connected via events and
8585what code is executed during state transitions.
8686
8787Schemas incorporate three generic types: ` State ` and ` Event ` , which we
88- defined above, and ` Subject ` , which represents an object associated with
88+ defined above, and ` Subject ` which represents an object associated with
8989a state machine. To keep things simple we won't use subject right now,
9090so we'll specify its type as ` Void ` :
9191
@@ -114,10 +114,10 @@ let schema = StateMachineSchema<Number, Operation, Void>(initialState: .One) { (
114114}
115115```
116116
117- You've probably expected nested ` switch ` statements after defining two
117+ You probably expected nested ` switch ` statements after defining two
118118` enum ` s. :wink :
119119
120- To understand the above snippet, it's helpful to look at initializer's
120+ To understand the above snippet, it's helpful to look at the initializer's
121121signature:
122122
123123``` swift
@@ -128,9 +128,9 @@ init(initialState: State,
128128We specify transition logic as a block. It accepts two arguments: the
129129current state and the event being handled. It returns an optional tuple
130130of a new state and an optional transition block. When the tuple is
131- ` nil ` , it indicates that there is no transition for given state-event
132- pair, i.e. given event should be ignored in given state. When the
133- tuple is non-` nil ` , it specifies the new state that machine should
131+ ` nil ` , it indicates that there is no transition for a given state-event
132+ pair, i.e. a given event should be ignored in a given state. When the
133+ tuple is non-` nil ` , it specifies the new state that the machine should
134134transition to and a block that should be called after the transition.
135135The transition block is optional. It gets passed a ` Subject ` object
136136as an argument, which we ignored in this example by using ` _ ` .
@@ -161,11 +161,11 @@ machine.didTransitionCallback = { (oldState, event, newState) in
161161
162162OK, what about the diagram? SwiftyStateMachine can create diagrams in
163163the [ DOT] [ ] graph description language. To create a diagram, we have
164- to use ` GraphableStateMachineSchema ` , which has the same initializer as
164+ to use ` GraphableStateMachineSchema ` which has the same initializer as
165165the regular ` StateMachineSchema ` , but requires state and event types to
166166conform to the [ ` DOTLabelable ` ] [ DOTLabelable ] protocol. This protocol
167167makes sure that all elements have nice readable labels and that they are
168- present on the graph at all (there's no way to automatically find all
168+ present on the graph (there's no way to automatically find all
169169` enum ` cases):
170170
171171 [ DOT ] : http://en.wikipedia.org/wiki/DOT_%28graph_description_language%29
@@ -200,7 +200,7 @@ extension Operation: DOTLabelable {
200200}
201201```
202202
203- Notice that above code doesn't use a ` switch ` statement in
203+ Notice that the above code doesn't use a ` switch ` statement in the
204204` DOTLabelableItems ` implementation. We won't get a compiler error after
205205adding a new case to an ` enum ` . To get some help from the compiler in
206206such situations, we can use the following trick:
@@ -210,7 +210,7 @@ static var DOTLabelableItems: [Number] {
210210 let items: [Number] = [.One , .Two , .Three ]
211211
212212 // Trick: switch on all cases and get an error if you miss any.
213- // Copy and paste following cases to the array above.
213+ // Copy and paste the following cases to the array above.
214214 for item in items {
215215 switch item {
216216 case .One , .Two , .Three : break
@@ -222,8 +222,8 @@ static var DOTLabelableItems: [Number] {
222222```
223223
224224When our types conform to ` DOTLabelable ` , we can define our structure as
225- before, but using ` GraphableStateMachineSchema ` . Then we can print the
226- diagram:
225+ before, but this time using ` GraphableStateMachineSchema ` . Then we can
226+ print the diagram:
227227
228228``` swift
229229let schema = GraphableStateMachineSchema// ...
@@ -249,15 +249,15 @@ digraph {
249249```
250250
251251[ On iOS] [ ] we can even have the graph file saved in the repo each time
252- we run the app in a simulator:
252+ we run the app in the simulator:
253253
254254 [ On iOS ] : https://github.com/macoscope/SwiftyStateMachine/commit/9b4963c26a934915b56d5023f84e42ff128f6a1d
255255
256256``` swift
257257schema.saveDOTDigraphIfRunningInSimulator (filepathRelativeToCurrentFile : " 123.dot" )
258258```
259259
260- DOT files can be viewed by a number of applications, including free
260+ DOT files can be viewed by a number of applications, including the free
261261[ Graphviz] [ ] . If you use [ Homebrew] [ ] , you can install Graphviz with
262262the following commands:
263263
@@ -268,7 +268,7 @@ the following commands:
268268 [ Graphviz ] : http://www.graphviz.org/
269269 [ Homebrew ] : http://brew.sh/
270270
271- Graphviz comes with a ` dot ` command, which can be used to generate graph
271+ Graphviz comes with a ` dot ` command which can be used to generate graph
272272images without launching the GUI app:
273273
274274 dot -Tpng 123.dot > 123.png
@@ -317,18 +317,18 @@ class MyViewController: UIViewController {
317317Development
318318-----------
319319
320- If you see a way to improve the project, please leave a comment, open an
321- [ issue] [ ] or start a [ pull request] [ ] . It's better to begin
322- with an issue rather than a pull request, though, because we might disagree
323- whether proposed change is an actual improvement. :wink :
320+ If you see a way to improve the project, please leave a comment, open
321+ an [ issue] [ ] or start a [ pull request] [ ] . It's better to begin with
322+ an issue rather than a pull request, though, because we might disagree
323+ whether the proposed change is an actual improvement. :wink :
324324
325325To run tests, install [ Carthage] [ ] and run ` carthage update ` to download
326326and build test frameworks.
327327
328- When introducing changes, please try to conform to the style present
329- in the project — both with respect to code formatting and commit
330- messages. We recommend following [ GitHub Swift Style Guide] [ ] with one
331- important difference: 4 spaces instead of tabs.
328+ When introducing changes, please try to conform to the style present in
329+ the project — both with respect to code formatting and commit messages.
330+ We recommend following [ GitHub Swift Style Guide] [ ] with one important
331+ difference: 4 spaces instead of tabs.
332332
333333Thanks! :v :
334334
0 commit comments