extension String {
func contains(find: String) -> Bool{
return self.rangeOfString(find) != nil
}
}
@IBOutlet weak var patientView: UITextField!
@IBAction func patientFunction(sender: UIButton!) {
}
@IBOutlet weak var donorView1: UITextField!
@IBOutlet weak var donorView2: UITextField!
@IBOutlet weak var donorView3: UITextField!
@IBOutlet weak var donorView4: UITextField!
@IBOutlet weak var donorView5: UITextField!
@IBOutlet weak var donorView6: UITextField!
@IBOutlet weak var donorView7: UITextField!
@IBOutlet weak var donorView8: UITextField!
@IBOutlet weak var Randomize: UIButton!
@IBAction func Randomize(sender: UIButton!) {
let quoteArray1 = [" A1,", " A2,", " A3,", " A11,", " A23, ", " A24,", " A25,", " A26,", " A29,", " A30,", " A31,", " A32, ", " A33,", " A34,", " A36, ", " A43,", " A66,", " A68, ", " A69,", " A74,", " A80,", ]
let quoteArray2 = [" B7,", " B8,", " B13,", " B14,", " B15, ", " B18,", " B27,", " B35,", " B37,", " B38,", " B39,", " B40,", " B41,", " B42,", " B44,", " B45,", " B46,", " B47,", " B48,", " B49,"," B50,", " B51,", " B52,", " B53,", " B54,", " B55,", " B56,", " B57,", " B58,", " B59,", " B67,"," B73,", " B78,", " B81,", " B82,", " B83," ]
let quoteArray3 = [" C1,", " C2,", " C3,", " C4,", " C5, ", " C6,", " C7,", " C8,", " C12,", " C14,", " C15,", " C16,", " C17,", " C18," ]
let quoteArray4 = [" DQ1,", " DQ2,", " DQ3,", " DQ4,", " DQ5,", " DQ6,", " DQ7,", " DQ8,", " DQ9,", ]
let quoteArray5 = [" DR1,", " DR3,", " DR4,", " DR7,", " DR8,", " DR9,", " DR10,", " DR11,", " DR12,", " DR13,", " DR14,", " DR15,", " DR16,", ]
let quoteArray6 = [" DP1,", " DP2,"]
let randomRange1 = UInt32(quoteArray1.count)
let randomRange2 = UInt32(quoteArray2.count)
let randomRange3 = UInt32(quoteArray3.count)
let randomRange4 = UInt32(quoteArray4.count)
let randomRange5 = UInt32(quoteArray5.count)
let randomRange6 = UInt32(quoteArray6.count)
let texty1 = quoteArray4 [Int(arc4random_uniform(randomRange4))] + quoteArray5 [Int(arc4random_uniform(randomRange5))] + quoteArray6 [Int(arc4random_uniform(randomRange6))]
let texty2 = quoteArray4 [Int(arc4random_uniform(randomRange4))] + quoteArray5 [Int(arc4random_uniform(randomRange5))] + quoteArray6 [Int(arc4random_uniform(randomRange6))]
let texty3 = quoteArray4 [Int(arc4random_uniform(randomRange4))] + quoteArray5 [Int(arc4random_uniform(randomRange5))] + quoteArray6 [Int(arc4random_uniform(randomRange6))]
let texty4 = quoteArray4 [Int(arc4random_uniform(randomRange4))] + quoteArray5 [Int(arc4random_uniform(randomRange5))] + quoteArray6 [Int(arc4random_uniform(randomRange6))]
let texty5 = quoteArray4 [Int(arc4random_uniform(randomRange4))] + quoteArray5 [Int(arc4random_uniform(randomRange5))] + quoteArray6 [Int(arc4random_uniform(randomRange6))]
let texty6 = quoteArray4 [Int(arc4random_uniform(randomRange4))] + quoteArray5 [Int(arc4random_uniform(randomRange5))] + quoteArray6 [Int(arc4random_uniform(randomRange6))]
let texty7 = quoteArray4 [Int(arc4random_uniform(randomRange4))] + quoteArray5 [Int(arc4random_uniform(randomRange5))] + quoteArray6 [Int(arc4random_uniform(randomRange6))]
let texty8 = quoteArray4 [Int(arc4random_uniform(randomRange4))] + quoteArray5 [Int(arc4random_uniform(randomRange5))] + quoteArray6 [Int(arc4random_uniform(randomRange6))]
let texty9 = quoteArray4 [Int(arc4random_uniform(randomRange4))] + quoteArray5 [Int(arc4random_uniform(randomRange5))] + quoteArray6 [Int(arc4random_uniform(randomRange6))]
self.patientView.text = quoteArray1 [Int(arc4random_uniform(randomRange1))] + quoteArray2 [Int(arc4random_uniform(randomRange2))] + quoteArray3 [Int(arc4random_uniform(randomRange3))] + texty1
self.donorView1.text = quoteArray1 [Int(arc4random_uniform(randomRange1))] + quoteArray2 [Int(arc4random_uniform(randomRange2))] + quoteArray3 [Int(arc4random_uniform(randomRange3))] + texty2
self.donorView2.text = quoteArray1 [Int(arc4random_uniform(randomRange1))] + quoteArray2 [Int(arc4random_uniform(randomRange2))] + quoteArray3 [Int(arc4random_uniform(randomRange3))] + texty3
self.donorView3.text = quoteArray1 [Int(arc4random_uniform(randomRange1))] + quoteArray2 [Int(arc4random_uniform(randomRange2))] + quoteArray3 [Int(arc4random_uniform(randomRange3))] + texty4
self.donorView4.text = quoteArray1 [Int(arc4random_uniform(randomRange1))] + quoteArray2 [Int(arc4random_uniform(randomRange2))] + quoteArray3 [Int(arc4random_uniform(randomRange3))] + texty5
self.donorView5.text = quoteArray1 [Int(arc4random_uniform(randomRange1))] + quoteArray2 [Int(arc4random_uniform(randomRange2))] + quoteArray3 [Int(arc4random_uniform(randomRange3))] + texty6
self.donorView6.text = quoteArray1 [Int(arc4random_uniform(randomRange1))] + quoteArray2 [Int(arc4random_uniform(randomRange2))] + quoteArray3 [Int(arc4random_uniform(randomRange3))] + texty7
self.donorView7.text = quoteArray1 [Int(arc4random_uniform(randomRange1))] + quoteArray2 [Int(arc4random_uniform(randomRange2))] + quoteArray3 [Int(arc4random_uniform(randomRange3))] + texty8
self.donorView8.text = quoteArray1 [Int(arc4random_uniform(randomRange1))] + quoteArray2 [Int(arc4random_uniform(randomRange2))] + quoteArray3 [Int(arc4random_uniform(randomRange3))] + texty9
let pv = self.patientView.text
let d1 = self.donorView1.text
let d2 = self.donorView2.text
let d3 = self.donorView3.text
let d4 = self.donorView4.text
let d5 = self.donorView5.text
let d6 = self.donorView6.text
let d7 = self.donorView7.text
let d8 = self.donorView8.text
print(pv!.contains(d1!)) // true
print(pv!.contains(d2!)) // true
print(pv!.contains(d3!)) // true
print(pv!.contains(d4!)) // true
print(pv!.contains(d5!)) // true
print(pv!.contains(d6!)) // true
print(pv!.contains(d7!)) // true
print(pv!.contains(d8!)) // true
}
}
Hi! I need to an efficient way to find if a string contains any character from another string. I'm trying to see if my patientView string contains a character from donorView1, 2, 3 etc. Is there a way to find if my self.patientView.text string contains a character from my self.donorView1.text string? Thank you!