Post

Replies

Boosts

Views

Activity

Reply to Swift Code Example using map inside of forEach
Thanks for the reply! I do need to preserve 'str' so I guess I need: let str = "SOME SEARCH TEXT" var tmpStr = str let letters = ["A","E","S"] let replacements = ["a", "e", "s"] letters.enumerated().forEach { (i,r) in tmpStr = String(tmpStr.map {$0 == Character(String(r)) ? Character(String(replacements[i])) : $0}); print(tmpStr) }
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’22
Reply to Swift Code Example using map inside of forEach
LOL! I wish I was that young. I'm just playing around with Swift5 and Xcode 11 on a 10 year old iMac. If you know, when I access the "Help" menu in my app it gives out a boilerplate message that I'd like to replace (this is importing Cocoa and using the Storyboard for macOS). (sorry for the late reply) TIA, SC
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’22
Reply to Swift Code Example using map inside of forEach
Thanks for the reply! I do need to preserve 'str' so I guess I need: let str = "SOME SEARCH TEXT" var tmpStr = str let letters = ["A","E","S"] let replacements = ["a", "e", "s"] letters.enumerated().forEach { (i,r) in tmpStr = String(tmpStr.map {$0 == Character(String(r)) ? Character(String(replacements[i])) : $0}); print(tmpStr) }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Mar ’22