# Chapter 12 p 275 - Expected expression after operator error

**URL:** <https://forums.kodeco.com/t/chapter-12-p-275-expected-expression-after-operator-error/42208>\
**Category:** iOS Apprentice\
**Created:** [May 3, 2018, 6:06pm UTC](https://forums.kodeco.com/t/chapter-12-p-275-expected-expression-after-operator-error/42208 "2018-05-03T18:06:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nidupb](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/nidupb/32/91476_2.png) [@nidupb](https://forums.kodeco.com/u/nidupb)\
**Post date:** [May 3, 2018, 6:06pm UTC](https://forums.kodeco.com/t/chapter-12-p-275-expected-expression-after-operator-error/42208/1 "2018-05-03T18:06:08Z")

</div>

Hi,

When I add the following to AddItemViewController.swift, I have on the line “let stringRange = Range(…)” the “Expected expression after operator”. I don’t get why. I compared with the files from the book, still don’t catch the mistake.

```
    func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
    
    let oldText = textField.text !
    let stringRange = Range(range, in:oldText)!
    let newText = oldText.replacingCharacters(in: stringRange, with: string)
    
    if newText.isEmpty {
        doneBarButton.isEnabled = false
    }else {
        doneBarButton.isEnabled = true
    }
    return true
    
}

```

Any ideas ?

---

<div class="post-metadata">

**Author:** ![nidupb](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/nidupb/32/91476_2.png) [@nidupb](https://forums.kodeco.com/u/nidupb)\
**Post date:** [May 3, 2018, 6:09pm UTC](https://forums.kodeco.com/t/chapter-12-p-275-expected-expression-after-operator-error/42208/2 "2018-05-03T18:09:53Z")

</div>

Found it ! There is an additional space in the “let oldText” line…

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [May 31, 2018, 5:36pm UTC](https://forums.kodeco.com/t/chapter-12-p-275-expected-expression-after-operator-error/42208/3 "2018-05-31T17:36:29Z")

</div>

@nidupb Thank you for the update. Really glad you managed to fix it.

---

<div class="post-metadata">

**Author:** ![system](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@system](https://forums.kodeco.com/u/system)\
**Post date:** [October 17, 2018, 10:18am UTC](https://forums.kodeco.com/t/chapter-12-p-275-expected-expression-after-operator-error/42208/4 "2018-10-17T10:18:16Z")

</div>

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