티스토리 뷰
filter 메서드를 사용하여 해당 menuList 배열을 섹션별로 빠르게 필터링 할 수 있습니다. 다음과 같이 표시됩니다.
let sectionZero = menuList.filter { (model) -> Bool in
return model.section == 0
}
let sectionOne = menuList.filter { (model) -> Bool in
return model.section == 1
}
menuList 및 tableView를 자주 다시로드하는 경우 고통 스러울 수 있지만 다차원 배열을 원하지 않는 경우 가능합니다.
출처
https://stackoverflow.com/questions/39920005
댓글