<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I am looking at the latest version of the “App Development with Swift” iBook on page 122. There’s a code example I’ll paste below.<div class=""><br class=""></div><div class=""><div class="">“Maybe you want to check if one string is somewhere within another string. You can use the contains(_:) method to return a Boolean value that indicates whether or not the substring was found.</div><div class=""> </div><div class="">let greeting = "Hi Rick, my name is Amy."</div><div class="">if greeting.contains("my name is") {</div><div class=""> print("Making an introduction")</div><div class="">}”</div><div class=""><br class=""></div><div class="">Excerpt From: Apple Education. “App Development with Swift.” Apple Inc. - Education, 2017. iBooks. <a href="https://itunes.apple.com/us/book/app-development-with-swift/id1219117996?mt=11" class="">https://itunes.apple.com/us/book/app-development-with-swift/id1219117996?mt=11</a></div></div><div class=""><br class=""></div><div class="">When I try to run this code, I get the following error:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">error: cannot convert value of type 'String' to expected argument type 'String.Element' (aka 'Character')</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">if greeting.contains("my name is") {</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> ^~~~~~~~~~~~</span></div></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">From what I can tell, the Swift 4 Strings are once again collections, so the contains method will only work with characters.</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">What can I use to find a substring inside a String in Swift 4?</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><b class=""><br class=""></b></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><b class="">Thank you!</b></span></div></body></html>