Whats meaning of nil => .State2 ? Got an error
Closed this issue · 2 comments
baryon commented
素晴らしいライブラリです
I tried from 0=>2, I got a error, whats meaning of nil => .State2, I think state2 can accept a transform from any other state, isn't it?
// tryState 0 => 2 => 1 => 2 => 1 => 0
machine <- (.State2, "Ping") //Any => 2, msg=Ping fatal error: unexpectedly found nil while unwrapping an Optional value
machine <- .State1
machine <- (.State2, "Hello")
machine <- (.State1, "Bye")
machine <- .State0 // fail: no 1 => 0
baryon commented
I got reason, please remove びっくりマーク ! from context.userInfo.
the "machine <- .State1" don't include userinfo, so it is nil, (context.userInfo!) will raise an exception.
machine.addRoute(.AnyState => .State2) { context in println("Any => 2, msg=\(context.userInfo)") }
machine.addRoute(.State2 => nil) { context in println("2 => Any, msg=\(context.userInfo)") }