# Swift Apprentice

**URL:** https://forums.kodeco.com/c/books/swift-apprentice/8.md

[Latest](https://forums.kodeco.com/latest.md) · [Categories](https://forums.kodeco.com/categories.md) · [Tags](https://forums.kodeco.com/tags.md)

---

## [About the Swift Apprentice category](https://forums.kodeco.com/t/about-the-swift-apprentice-category/22)

<div class="topic-metadata">

**Author:** [@rwenderlich](https://forums.kodeco.com/u/rwenderlich)\
**Replies:** 2\
**Last updated:** [April 23, 2020, 4:37am UTC](https://forums.kodeco.com/t/about-the-swift-apprentice-category/22 "2020-04-23T04:37:27Z")

</div>

These are the official forums for the Swift Apprentice, our book on beginning Swift development. This is the place to ask any questions you may have about the book. We hope you enjoy the book! :\]

---

## [No Swift Apprentice update, instead - new Fundamentals book](https://forums.kodeco.com/t/no-swift-apprentice-update-instead-new-fundamentals-book/184616)

<div class="topic-metadata">

**Author:** [@horb](https://forums.kodeco.com/u/horb)\
**Replies:** 4\
**Last updated:** [March 6, 2023, 2:08am UTC](https://forums.kodeco.com/t/no-swift-apprentice-update-instead-new-fundamentals-book/184616 "2023-03-06T02:08:14Z")

</div>

Hi RW Team, I purchased the Swift Apprentice book a while ago in order to have an access to content updates. Now instead we get another book called Fundamentals. Do I get an access to it by default? I have my doubts i…

---

## [Chapter 8 - Capturing from the enclosing scope](https://forums.kodeco.com/t/chapter-8-capturing-from-the-enclosing-scope/181521)

<div class="topic-metadata">

**Author:** [@labramalino](https://forums.kodeco.com/u/labramalino)\
**Replies:** 1\
**Last updated:** [December 10, 2022, 11:34am UTC](https://forums.kodeco.com/t/chapter-8-capturing-from-the-enclosing-scope/181521 "2022-12-10T11:34:53Z")

</div>

Why does this work: func countingClosure() -\> () -\> Int { var counter = 0 let incrementCounter: () -\> Int = { counter += 1 return counter } return incrementCounter } and this not? func countingClosure(…

---

## [Mini exercise Chapter 10 IsInDeliveryRange](https://forums.kodeco.com/t/mini-exercise-chapter-10-isindeliveryrange/181301)

<div class="topic-metadata">

**Author:** [@vulcanccit](https://forums.kodeco.com/u/vulcanccit)\
**Replies:** 5\
**Last updated:** [December 3, 2022, 3:49am UTC](https://forums.kodeco.com/t/mini-exercise-chapter-10-isindeliveryrange/181301 "2022-12-03T03:49:54Z")

</div>

I am very new to Swift, I come from a C# background but I was junior level there,I have bought some Swift books recently and I am reading them all concurrently to Swift Apprentice, but I am really liking how this book is…

---

## [How do you get this book via an E-Reader?](https://forums.kodeco.com/t/how-do-you-get-this-book-via-an-e-reader/181325)

<div class="topic-metadata">

**Author:** [@vulcanccit](https://forums.kodeco.com/u/vulcanccit)\
**Replies:** 2\
**Last updated:** [December 2, 2022, 5:30pm UTC](https://forums.kodeco.com/t/how-do-you-get-this-book-via-an-e-reader/181325 "2022-12-02T17:30:16Z")

</div>

I just subscribed to the Professional subscription. I have found where I can read the book via a web browser, but I had emailed sales a few weeks back and they said I can access via an E-Pub type reader…I have a Kindle……

---

## [Chapter 19.3 Keypaths](https://forums.kodeco.com/t/chapter-19-3-keypaths/179314)

<div class="topic-metadata">

**Author:** [@scopes](https://forums.kodeco.com/u/scopes)\
**Replies:** 1\
**Last updated:** [October 5, 2022, 8:27pm UTC](https://forums.kodeco.com/t/chapter-19-3-keypaths/179314 "2022-10-05T20:27:26Z")

</div>

This section explains how to use keypaths, but not why we’d want to or how they are useful. Would be nice to add this.

---

## [How to guarantee reference being unowned?](https://forums.kodeco.com/t/how-to-guarantee-reference-being-unowned/177467)

<div class="topic-metadata">

**Author:** [@exchessplayerh](https://forums.kodeco.com/u/exchessplayerh)\
**Replies:** 0\
**Last updated:** [August 28, 2022, 12:50pm UTC](https://forums.kodeco.com/t/how-to-guarantee-reference-being-unowned/177467 "2022-08-28T12:50:51Z")

</div>

Besides using unowned instead of weak, what can be done in order to guarantee that the reference passed to the constructor is not created during constructor invocation? Namely, if the class has a weak reference/unowned …

---

## [Chapter 3 doesn't mention logical NOT](https://forums.kodeco.com/t/chapter-3-doesnt-mention-logical-not/176248)

<div class="topic-metadata">

**Author:** [@exchessplayerh](https://forums.kodeco.com/u/exchessplayerh)\
**Replies:** 0\
**Last updated:** [August 4, 2022, 1:31pm UTC](https://forums.kodeco.com/t/chapter-3-doesnt-mention-logical-not/176248 "2022-08-04T13:31:54Z")

</div>

Logical NOT aka !a is not mentioned when when discussing operations on boolean types. Is there a reason for that? A couple of sentences would be necessary - not everything can be expressed using AND an OR - you have to u…

---

## [Basic to advanced swift](https://forums.kodeco.com/t/basic-to-advanced-swift/162794)

<div class="topic-metadata">

**Author:** [@hassanwa](https://forums.kodeco.com/u/hassanwa)\
**Replies:** 1\
**Last updated:** [July 7, 2022, 4:56am UTC](https://forums.kodeco.com/t/basic-to-advanced-swift/162794 "2022-07-07T04:56:52Z")

</div>

I should study which book of raywenderlich for studying swift from basic to advanced level? which book is the best? what is the difference in the books of swift apprentice and iOS apprentice?

---

## [Chapter 18 fileprivate](https://forums.kodeco.com/t/chapter-18-fileprivate/174291)

<div class="topic-metadata">

**Author:** [@schluter](https://forums.kodeco.com/u/schluter)\
**Replies:** 1\
**Last updated:** [July 7, 2022, 4:49am UTC](https://forums.kodeco.com/t/chapter-18-fileprivate/174291 "2022-07-07T04:49:35Z")

</div>

In the section discussing private and fileprivate concerning class CheckAccount, the following statement is made: “Right now, nothing is preventing a haphazard coder who doesn’t read the documentation from creating a Ch…

---

## [Ambiguous Subscript](https://forums.kodeco.com/t/ambiguous-subscript/172219)

<div class="topic-metadata">

**Author:** [@jinkazama](https://forums.kodeco.com/u/jinkazama)\
**Replies:** 2\
**Last updated:** [June 1, 2022, 12:57am UTC](https://forums.kodeco.com/t/ambiguous-subscript/172219 "2022-06-01T00:57:59Z")

</div>

extension Array { subscript(i index: Int) -\> (String, String)? { guard let value = self\[index\] as? Int else { return nil } switch (value \>= 0, abs(value % 2)) { ca…

---

## [Challenge 2 Of Chapter 13 Problem](https://forums.kodeco.com/t/challenge-2-of-chapter-13-problem/171887)

<div class="topic-metadata">

**Author:** [@jinkazama](https://forums.kodeco.com/u/jinkazama)\
**Replies:** 1\
**Last updated:** [May 26, 2022, 3:12pm UTC](https://forums.kodeco.com/t/challenge-2-of-chapter-13-problem/171887 "2022-05-26T15:12:37Z")

</div>

I am not sure if it is just a mishap from the editorial team, but by no mean can we initialize an object from any of the struct or class below. Anyway the challenge question is this Your challenge here is to build a se…

---

## [About Closure with $0 and $1](https://forums.kodeco.com/t/about-closure-with-0-and-1/167664)

<div class="topic-metadata">

**Author:** [@chondro](https://forums.kodeco.com/u/chondro)\
**Replies:** 1\
**Last updated:** [March 26, 2022, 12:43pm UTC](https://forums.kodeco.com/t/about-closure-with-0-and-1/167664 "2022-03-26T12:43:18Z")

</div>

Hello all. I wanna testing with $0 and $1, when i use it for closure. I search in case implemtentaion with arrayVariabel.sorted(by:{$0 \< $1}). So how to implement it in that case? thank u

---

## [How to change alignment in MemoryLayout](https://forums.kodeco.com/t/how-to-change-alignment-in-memorylayout/161564)

<div class="topic-metadata">

**Author:** [@richmond\_jam](https://forums.kodeco.com/u/richmond_jam)\
**Replies:** 0\
**Last updated:** [January 7, 2022, 9:10am UTC](https://forums.kodeco.com/t/how-to-change-alignment-in-memorylayout/161564 "2022-01-07T09:10:28Z")

</div>

Hello, in Swift We can get a default alignment value of Struct like this: MemoryLayout.alignment Now ,if I wanna change the value how to do it?

---

## [Chap 29 \[Domain\] not in scope](https://forums.kodeco.com/t/chap-29-domain-not-in-scope/161483)

<div class="topic-metadata">

**Author:** [@marvmax](https://forums.kodeco.com/u/marvmax)\
**Replies:** 0\
**Last updated:** [January 3, 2022, 9:37pm UTC](https://forums.kodeco.com/t/chap-29-domain-not-in-scope/161483 "2022-01-03T21:37:24Z")

</div>

I imported SwiftUI like the book demo does when I type in func fetchDomains() async throws -\> \[Domain\] { \[\] // Fill in the implementation later } I get “Cannot find type ‘Domain’ in scope” with the D in the \[Domain\] …

---

## [Errata for Swift Apprentice 7th Edition](https://forums.kodeco.com/t/errata-for-swift-apprentice-7th-edition/154966)

<div class="topic-metadata">

**Author:** [@jellodiil](https://forums.kodeco.com/u/jellodiil)\
**Replies:** 3\
**Last updated:** [December 28, 2021, 12:34am UTC](https://forums.kodeco.com/t/errata-for-swift-apprentice-7th-edition/154966 "2021-12-28T00:34:21Z")

</div>

Creating this topic to catch any typos and bugs in the 7th Edition of Swift Apprentice.

---

## [Challenge 2: It’s prime time](https://forums.kodeco.com/t/challenge-2-it-s-prime-time/153601)

<div class="topic-metadata">

**Author:** [@ahmednagy](https://forums.kodeco.com/u/ahmednagy)\
**Replies:** 1\
**Last updated:** [November 8, 2021, 1:22pm UTC](https://forums.kodeco.com/t/challenge-2-it-s-prime-time/153601 "2021-11-08T13:22:38Z")

</div>

Can someone explain how this function works please? func isPrime(\_ number: Int) -\> Bool { if number \< 0 { return false } /\* We handle these cases up front because we want to make sure the range 2...root …

---

## [PDF version for Swift Apprentice - RESOLVED](https://forums.kodeco.com/t/pdf-version-for-swift-apprentice-resolved/142894)

<div class="topic-metadata">

**Author:** [@kumaresanlearner](https://forums.kodeco.com/u/kumaresanlearner)\
**Replies:** 2\
**Last updated:** [October 1, 2021, 3:28am UTC](https://forums.kodeco.com/t/pdf-version-for-swift-apprentice-resolved/142894 "2021-10-01T03:28:05Z")

</div>

Hi, The ePub version of the 6th edition is available, but there is no link for the PDF version. Older editions do have PDFs. When will the PDF be made available? Thanks, Kumaresan

---

## [Swift : Want to send data from UITabBarController to NavigationController](https://forums.kodeco.com/t/swift-want-to-send-data-from-uitabbarcontroller-to-navigationcontroller/148628)

<div class="topic-metadata">

**Author:** [@tada777](https://forums.kodeco.com/u/tada777)\
**Replies:** 1\
**Last updated:** [September 25, 2021, 6:17am UTC](https://forums.kodeco.com/t/swift-want-to-send-data-from-uitabbarcontroller-to-navigationcontroller/148628 "2021-09-25T06:17:29Z")

</div>

I am Swift beginner. Don’t know how to send data from UITabBarController to NavigationController→UITableViewController I confirmed data sent from UITabBarController to UIViewController with code 1 below. (Code 1) if …

---

## [Ch. 18: Creating a test class](https://forums.kodeco.com/t/ch-18-creating-a-test-class/135793)

<div class="topic-metadata">

**Author:** [@daverobeson](https://forums.kodeco.com/u/daverobeson)\
**Replies:** 4\
**Last updated:** [August 17, 2021, 9:53am UTC](https://forums.kodeco.com/t/ch-18-creating-a-test-class/135793 "2021-08-17T09:53:23Z")

</div>

Not sure if this another issue in a newer version of Xcode than the book’s author was using, but… XCTAssertEqual doesn’t appear to work in a playground in Xcode 12.4. Can the author confirm whether Apple broke this, or i…

---

## [Chapter 4 Mini-exercises issue?](https://forums.kodeco.com/t/chapter-4-mini-exercises-issue/146010)

<div class="topic-metadata">

**Author:** [@mintcollie](https://forums.kodeco.com/u/mintcollie)\
**Replies:** 0\
**Last updated:** [August 11, 2021, 3:46pm UTC](https://forums.kodeco.com/t/chapter-4-mini-exercises-issue/146010 "2021-08-11T15:46:34Z")

</div>

Hello everyone, Im not sure if this is a possible error in the book or if I just missed reading over a certain part. Regardless I would appreciate the help figuring this out! In Chapter 4 the Mini-exercises the third q…

---

## [Chapter 9 Show Alert](https://forums.kodeco.com/t/chapter-9-show-alert/141624)

<div class="topic-metadata">

**Author:** [@briviere](https://forums.kodeco.com/u/briviere)\
**Replies:** 1\
**Last updated:** [July 1, 2021, 1:27am UTC](https://forums.kodeco.com/t/chapter-9-show-alert/141624 "2021-07-01T01:27:18Z")

</div>

In chapter 9 Alert section there is a compile error in setting the showlert = true within the do catch init statement.\` I noticed that the final project in chapter 9 also has the same compile error if I uncomment the sho…

---

## [Chapter 8 shortened closures](https://forums.kodeco.com/t/chapter-8-shortened-closures/138181)

<div class="topic-metadata">

**Author:** [@pawi552](https://forums.kodeco.com/u/pawi552)\
**Replies:** 1\
**Last updated:** [July 1, 2021, 2:00am UTC](https://forums.kodeco.com/t/chapter-8-shortened-closures/138181 "2021-07-01T02:00:18Z")

</div>

var multiplyClosure = { (a, b) in a\*b } Is causing error “Ambiguous use of operator ‘\*’” Same error for var multiplyClousure = { $0 \* $1 }

---

## [Ch.18 "Cannot find type 'BasicAccount' in scope"](https://forums.kodeco.com/t/ch-18-cannot-find-type-basicaccount-in-scope/136813)

<div class="topic-metadata">

**Author:** [@jasper8777](https://forums.kodeco.com/u/jasper8777)\
**Replies:** 1\
**Last updated:** [May 23, 2021, 2:57pm UTC](https://forums.kodeco.com/t/ch-18-cannot-find-type-basicaccount-in-scope/136813 "2021-05-23T14:57:34Z")

</div>

Hi all, in this chapter, when I organized the code from playground to separate files, Xcode kept showing me this error saying it cannot find BasicAccount in scope, while the BasicAccount class and the Account protocol h…

---

## [Would I intentionally crash an application, really?](https://forums.kodeco.com/t/would-i-intentionally-crash-an-application-really/135762)

<div class="topic-metadata">

**Author:** [@botchedphoto](https://forums.kodeco.com/u/botchedphoto)\
**Replies:** 2\
**Last updated:** [May 13, 2021, 2:17pm UTC](https://forums.kodeco.com/t/would-i-intentionally-crash-an-application-really/135762 "2021-05-13T14:17:08Z")

</div>

I copied the paragraph below from Chapter 5. I think the use of “crash” there may be inappropriate. If I’m flying in an airplane and something goes wrong on the way to my destination, I don’t want to crash it. Instead, I…

---

## [Chapter 18 Challenge 2: Stack- why is stack implemented as a struct?](https://forums.kodeco.com/t/chapter-18-challenge-2-stack-why-is-stack-implemented-as-a-struct/136859)

<div class="topic-metadata">

**Author:** [@jasper8777](https://forums.kodeco.com/u/jasper8777)\
**Replies:** 0\
**Last updated:** [April 4, 2021, 9:36pm UTC](https://forums.kodeco.com/t/chapter-18-challenge-2-stack-why-is-stack-implemented-as-a-struct/136859 "2021-04-04T21:36:48Z")

</div>

Hi all! I’m wondering why is Stack implemented as a struct? I’ve implemented Stack as a class thinking because I would need to store the content of the Stack in a data structure that would persist in the memory for a lo…

---

## [Chapter 18: "Sources" files not being recognized](https://forums.kodeco.com/t/chapter-18-sources-files-not-being-recognized/131170)

<div class="topic-metadata">

**Author:** [@nollda](https://forums.kodeco.com/u/nollda)\
**Replies:** 4\
**Last updated:** [April 3, 2021, 8:53pm UTC](https://forums.kodeco.com/t/chapter-18-sources-files-not-being-recognized/131170 "2021-04-03T20:53:28Z")

</div>

Hi, I’m following through Chapter 18 and have come to the section on “internal, public, and open”. I’ve added the two Sources files, “Account.swift” and “Checking.swift”. I have changed all of the applicable class nam…

---

## [Chapter 1: Challenges - Question 8](https://forums.kodeco.com/t/chapter-1-challenges-question-8/130236)

<div class="topic-metadata">

**Author:** [@rolovee](https://forums.kodeco.com/u/rolovee)\
**Replies:** 1\
**Last updated:** [March 31, 2021, 11:54pm UTC](https://forums.kodeco.com/t/chapter-1-challenges-question-8/130236 "2021-03-31T23:54:59Z")

</div>

Can someone explain how you can use modulo to truncate a number to a range that you want? Maybe I’m not understanding what exactly the text means by this. For example, say we have the integer 2\_453\_922. Does that mean t…

---

## [Possible to buy ebook?](https://forums.kodeco.com/t/possible-to-buy-ebook/134825)

<div class="topic-metadata">

**Author:** [@jasmith](https://forums.kodeco.com/u/jasmith)\
**Replies:** 0\
**Last updated:** [March 11, 2021, 10:12am UTC](https://forums.kodeco.com/t/possible-to-buy-ebook/134825 "2021-03-11T10:12:34Z")

</div>

If I have a membership is it also possible to buy / download an ePub or pdf version? I very much prefer to read in Books vs the web (with highlighting, bookmarks etc). Thanks!

---

## [Chapter 21 Value of type 'Result\<String, TutorialError\>' has no member 'get'](https://forums.kodeco.com/t/chapter-21-value-of-type-result-string-tutorialerror-has-no-member-get/111260)

<div class="topic-metadata">

**Author:** [@steveb\_la](https://forums.kodeco.com/u/steveb_la)\
**Replies:** 2\
**Last updated:** [March 17, 2021, 12:00pm UTC](https://forums.kodeco.com/t/chapter-21-value-of-type-result-string-tutorialerror-has-no-member-get/111260 "2021-03-17T12:00:40Z")

</div>

Swift Apprentice 5.0 I’m getting the message Value of type ‘Result\<String, TutorialError\>’ has no member ‘get’ and can’t figure where or how to fix this. //. \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*code begin. \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*// impor…

[Next page](https://forums.kodeco.com/c/books/swift-apprentice/8.md?page=1)
