
AViewModel과 UITableVIewDiffableDataSource 활용하기 ※ 스토리보드로 진행 ViewController import UIKit class ViewController: UIViewController { @IBOutlet weak var tableView: UITableView! private let viewModel = ViewModel() override func viewDidLoad() { super.viewDidLoad() tableView.delegate = self viewModel.makeTableView(tableView: tableView) } } ViewModel - custom cell일 경우, register해주는 작업도 필요 - 반드시 append 해주는 ..

Main 스토리보드와 연결된 ViewController에 테이블뷰 만들기 더보기 import UIKit class ViewController: UIViewController { @IBOutlet weak var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() tableView.dataSource = self } extension ViewController: UITableViewDataSource { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 100 } func tableView(_ tableView:..

유용한 사이트 정리 0. 프로그래머스 코딩 테스트 준비하기 위한 사이트 https://programmers.co.kr/ 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. Leet Code 코테 준비 사이트 https://leetcode.com/ LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get..

Preprocessor (전처리) 앱을 만들다 보면 배포 전에는 개발용 서버를, 배포 시에는 실제 서버를 사용하는 경우가 많음 그럴 때 build configuration을 바꿔가며 설정해줄 수 있음 프로젝트에서 option을 누른채로 해당 프로젝트 이름을 누르면 아래와 같은 창이 나옴. 여기서 build configuration을 설정 가능 사용하는 방법은 #과 함께 써주면 됨. 가장 간단하게 build configuration을 "Debug"로 설정한 후 아래 코드를 실행해보면 import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // 전처리 (preprocessor) ..

MapKit 1 ※ 프로젝트 이름을 framework와 동일하게 지으면 안됨 ※ 예를들어 MapKit이라고 이름 지으면 안됨 기본 코드 설정 더보기 import MapKit class ViewController: UIViewController { private let mapView = MKMapView() private let mapButton = UIButton(type: .system) override func viewDidLoad() { super.viewDidLoad() setUI() } @objc func buttonTapped(_ sender: UIButton) { print(#function) } } extension ViewController { private func setUI() { m..

async/await async / await 사용이유 - 콜백 지옥 - 에러 처리에서 실수 가능성 있음 기본코드 ⬇️ 더보기 model import Foundation // Codable = Encodable + Decodable struct Quote: Decodable { let content: String } error import Foundation enum NetworkError: Error { case badResponse case communicationError case decodeFailed case noData } controller import UIKit class ViewController: UIViewController { let networkService = NetworkSer..

Collapsed TableView 기본 코드 ⬇️ 더보기 import UIKit class ViewController: UIViewController { let tableViewData = [ ["1", "2", "3", "4", "5"], ["1", "2", "3", "4", "5"], ["1", "2", "3", "4", "5"], ["1", "2", "3", "4", "5"], ["1", "2", "3", "4", "5"], ] // MARK: -Properties let tableView: UITableView = { let tableView = UITableView() return tableView }() // MARK: -Life Cycles override func viewDidLoad()..

Result 어떤 결과값이 성공 or 실패로 나뉜다면 Result로 쓰면 좋음. 기본코드⬇️ 더보기 class ViewController: UIViewController { let centerLabel = UILabel() override func viewDidLoad() { super.viewDidLoad() setUI() } } // MARK: -URLSession extension ViewController { func setUI() { setConstraints() setAttributes() } func setConstraints() { view.addSubview(centerLabel) centerLabel.translatesAutoresizingMaskIntoConstraints = fals..
- Total
- Today
- Yesterday