I want to set a string variable and want to keep it always lowercase.
This is my code :
var alwaysLowercaseString : String? {
didSet{
alwaysLowercaseString = alwaysLowerCaseString!.lowercaseString
}
}
But when I use it, it goes into a infinite loop. How can I solve this problem?
I stand corrected, this is the correct approach. LeoDabus deserves the credit for this answer:
var alwaysLowercaseString : String? {
didSet{
alwaysLowercaseString = alwaysLowercaseString?.lowercaseString
print(alwaysLowercaseString)
}
}