Hi I have two arrays.
var firstArray = ["Hi", "Hello", "Mother"]
var secondArray = ["Yo", "Yee", "Father"]
Now say I did a println("I saw Johnny and said Hi") but it would really replace it with my second string object which is "Yo"
So pretty much replace everything in the first array with the second array in the exactly order they're in anytime someone typed any literal string in the first array? I'm trying to do this in swift. I tried looping through the first array with stringByReplacingOccurrencesOfString but I'm not sure how I can implement an NSArray into it. Any help?
What if I did below?
var myString = "Hello this is a test."
var myDictionary = ["Hello":"Yo"]
for (originalWord, newWord) in myDictionary {
let newString = aString.stringByReplacingOccurrencesOfDictionary(myString, withString:newWord, options: NSStringCompareOptions.LiteralSearch, range: nil)
}
I still can't figure out how if I put that into an println("hello how are you?) if it'll automatically know to replace "hello" every time it's entered in the println statement with "yo"