[swift-users] Protocol composition results in EXC_BAD_ACCESS
Zhao Xin
owenzx at gmail.com
Mon Apr 3 10:58:53 CDT 2017
Why not making State as a class? EffectiveState should be subclass of State.
Zhaoxin
On Mon, Apr 3, 2017 at 11:08 PM, Rudolf Adamkovič via swift-users <
swift-users at swift.org> wrote:
> On 3 Apr 2017, at 16:48, Adrian Zubarev <adrian.zubarev at devandartist.com>
> wrote:
>
> Why do you cast against an existential in first place?
>
>
> To avoid force-unwrap at the end here:
>
> class Store {
>
> var state: State
>
> // ...
>
> func processScheduledActions() {
>
> guard var effectfulState = state as? Effectful else {
> return
> }
>
> while let actions = effectfulState.scheduledActions.flush() {
> for action in actions {
> delegate?.store(self, didRequest: action)
> }
> }
>
> state = effectfulState as! State
>
>
> }
>
> }
>
> Thank you!
>
> R+
>
>
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170403/5d0895c7/attachment.html>
More information about the swift-users
mailing list