Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Range Question

var sentence = "All boys do a really good job cleaning."

use the range() method to locate the word "do" in the sentence and assign the range to a variable.

2 Answers

I did this from my phone so it's not tested. You may need an if let.

let range = sentence.range(of: "do")

wow, it is more simple than I imagine. thanks

Did it work?

put this in xcode also showed me the same result in the pane but not in the console I see that both ways give the same results, thinking logically for future construts having the variable [range] can be useful in how many ways?

var sentence = "All boys do a really good cleaning"

sentence.range(of: "do")

yes it worked also, really apologize I was in a rush and typed with my caps lock on. embarrassed.

Definitely is useful with search results for a table.