
@IBOutlet 컬렉션을 이용하여 4가지 버튼을 하나로 묶고 한번에 기능 구현하기

let wordArray = ["애빼시", "킹받네", "갓생", "댕댕이", "쌉가능", "꾸안꾸"]
func hashtagButtonSetup(){
hashtagButton.setTitle("#\(wordArray.randomElement()!)", for: .normal)
hashtagButton.setTitleColor(.purple, for: .normal)
hashtag2Button.setTitle("#\(wordArray.randomElement()!)", for: .normal)
hashtag2Button.setTitleColor(.purple, for: .normal)
hashtag3Button.setTitle("#\(wordArray.randomElement()!)", for: .normal)
hashtag3Button.setTitleColor(.purple, for: .normal)
hashtag4Button.setTitle("#\(wordArray.randomElement()!)", for: .normal)
hashtag4Button.setTitleColor(.purple, for: .normal)
}
@IBOutlet var hashtagBugtton : [UIButton]!
for (_, button) in hashtagBugtton.enumerated(){
button.setTitle("#\(wordArray.randomElement()!)", for: .normal)
button.setTitleColor(.purple, for: .normal)
1. 4개의 버튼 배열을 IBOutletCollecion을 이용해서 하나로 묶음.
2. enumerated() 메서드를 이용하여 (index, button)으로 정렬
3. for 문을 통해 배열의 random 단어를 제목으로 설정. 정렬한 것에서 랜덤단어를 꺼내기때문에 겹칠일이 없음 !



