<aside> 🐫 변수명, 상수명, 함수명은 lowerCamelCase로 작성합니다.
</aside>
<aside> ☝ 가독성을 위해 한 줄에 하나의 문장만 작성합니다.
</aside>
<aside> ❕ 축약형을 사용하지 않습니다.
좋은 예
class LoginViewController{}
let loginButton = UIButton()
나쁜 예
class LoginVC{}
let loginBtn = UIButton()
</aside>
<aside> ❕ 모듈 임포트는 알파벳 순으로 정렬합니다. 내장 프레임워크를 먼저 임포트하고, 빈 줄로 구분하여 서드파티 프레임워크를 임포트합니다.
import UIKit
import SwiftyColor
import SwiftyImage
import Then
import URLNavigator
</aside>
<aside> ❕ Delegate 메서드는 프로토콜명으로 네임스페이스를 구분합니다.
좋은 예
protocol UserCellDelegate {
func userCellDidSetProfileImage(_ cell: UserCell)
func userCell(_ cell: UserCell, didTapFollowButtonWith user: User)
}
나쁜 예
protocol UserCellDelegate {
func didSetProfileImage()
func followPressed(user: User)
// `UserCell`이라는 클래스가 존재할 경우 컴파일 에러 발생
func UserCell(_ cell: UserCell, didTapFollowButtonWith user: User)
}
</aside>
<aside> ❕ 주석
///
를 사용해서 문서화에 사용되는 주석을 남깁니다./// 사용자 프로필을 그려주는 뷰
class ProfileView: UIView {
/// 사용자 닉네임을 그려주는 라벨
var nameLabel: UILabel!
}
// MARK:
를 사용해서 연관된 코드를 구분짓습니다.// MARK: Init
override init(frame: CGRect) {
// doSomething()
}
deinit {
// doSomething()
}
// MARK: Layout
override func layoutSubviews() {
// doSomething()
}
// MARK: Actions
override func menuButtonDidTap() {
// doSomething()
}
</aside>