Использование awk только
foo="uNcapItalizedstrIng"
echo $foo | awk '{print toupper(substr($0,0,1))tolower(substr($0,2))}'
Отключение каждого элемента перед его настройкой не является проблемой.
Однако, если вы все еще хотите обработать только отмеченный элемент, вы можете сделать это с помощью условного цикла или карты.
Вот пример цикла for:
//Class representing the item.
class Item {
var isChecked = false
}
//Array of 3 items.
var items: [Item] = [Item(), Item(), Item()]
//Function that should be called (as @IBAction) when an item is tapped.
func itemIsTapped(itemTag: Int) {
selectItemAt(index: itemTag)
}
//Function that unselected the checked item and select the one that should be.
func selectItemAt(index: Int) {
//This is the part where you UNCHECKED ONLY the CHECKED item.
for item in items where item.isChecked {
item.isChecked = false
}
items[index].isChecked = true
}