Chapter 7 challenge : convert issue


I am trying to resolve the chapter 7 challange, but i get a EXC_BAD_ACCESS error when calling the convert closure. Same happens in the challenge_final project… Any fix?


Hey, @marinpostma, are there any messages being logged in the console that can help us understand the issue? If you can also share the related code that you have written and the version of Xcode that you are using that would be great!

Thanks :slightly_smiling_face:

this happens with the provided finished challenge, screenshot joined.
my xcode version : Version 9.0 beta 6 (9M214v)

Thanks for that @marinpostma! Currently RxSwift by Tutorials is only updated for Xcode 8.3 so there may be issues when trying to perform any of the tasks in Xcode 9.

Could you please download and install Xcode 8.3.3 from the Apple developer site and see if it fixes things?


With Xcode 9, I solved this by changing the convert closure as follows:

let convert: (String) -> UInt? = { value in
    if let number = UInt(value),
        number < 10 {
        return number

    let convert: [String: UInt] = [
        "abc": 2, "def": 3, "ghi": 4,
        "jkl": 5, "mno": 6, "pqrs": 7,
        "tuv": 8, "wxyz": 9

    for (letters, number) in convert {
        if letters.contains(value.lowercased()) {
            return number

    return nil

For some reason Xcode 9 hates the forEach loop as used in the book.

1 Like

forEach working, but with explicit parameters
convert.forEach({ (key, val) in …

This topic was automatically closed after 166 days. New replies are no longer allowed.