# Chapter 13 (Iterator) - Tutorial example doesn't use Iterator pattern

**URL:** <https://forums.kodeco.com/t/chapter-13-iterator-tutorial-example-doesnt-use-iterator-pattern/82469>\
**Category:** Design Patterns by Tutorials\
**Created:** [September 21, 2019, 2:12pm UTC](https://forums.kodeco.com/t/chapter-13-iterator-tutorial-example-doesnt-use-iterator-pattern/82469 "2019-09-21T14:12:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wadedunk](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/wadedunk/32/110937_2.png) [@wadedunk](https://forums.kodeco.com/u/wadedunk)\
**Post date:** [September 21, 2019, 2:12pm UTC](https://forums.kodeco.com/t/chapter-13-iterator-tutorial-example-doesnt-use-iterator-pattern/82469/1 "2019-09-21T14:12:09Z")

</div>

In chapter 13 to demonstrate iterator pattern in action, author added Filter conformance to Sequence protocol.  
However at the moment of its usage in method addAnnotations(), for in loop launched over array filter.businesses, not over filter (whose type supports iteration).

Now:

```auto
    for business in filter.businesses {
      guard let viewModel = annotationFactory.createBusinessMapViewModel(for: business) else {
        continue
      }

```

Expected:

```auto
    for business in filter {
      guard let viewModel = annotationFactory.createBusinessMapViewModel(for: business) else {
        continue
      }

```

---

<div class="post-metadata">

**Author:** ![jstrawn](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jstrawn/32/104245_2.png) [@jstrawn](https://forums.kodeco.com/u/jstrawn)\
**Post date:** [September 26, 2019, 4:46pm UTC](https://forums.kodeco.com/t/chapter-13-iterator-tutorial-example-doesnt-use-iterator-pattern/82469/2 "2019-09-26T16:46:09Z")

</div>

Wow this is a great catch! Thanks, I can’t believe that slipped through. I will update this in the next edition.

---

<div class="post-metadata">

**Author:** ![jstrawn](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jstrawn/32/104245_2.png) [@jstrawn](https://forums.kodeco.com/u/jstrawn)\
**Post date:** [October 1, 2019, 2:41pm UTC](https://forums.kodeco.com/t/chapter-13-iterator-tutorial-example-doesnt-use-iterator-pattern/82469/3 "2019-10-01T14:41:16Z")

</div>

I looked into this and it turned out that the instructions in the book did use `filter`, but somehow the final example project still used `filter.businesses`. It has been updated and this fix will be included in the Swift 5 version of the book!

---

<div class="post-metadata">

**Author:** ![wadedunk](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/wadedunk/32/110937_2.png) [@wadedunk](https://forums.kodeco.com/u/wadedunk)\
**Post date:** [October 2, 2019, 5:04am UTC](https://forums.kodeco.com/t/chapter-13-iterator-tutorial-example-doesnt-use-iterator-pattern/82469/4 "2019-10-02T05:04:05Z")

</div>

> [@jstrawn](#):
>
> d into this and it turned out that the instructions in the book did use `filter` , but somehow the final example project still used `filter.businesses` . It has been updated and this fix will be included in the Swift

Cool, thanks for fixing that
