꾸준히 안타치기
정적변수 Static 본문
반응형
정적변수 (Static 변수) :
인스턴스 생성없이도 사용가능함
한 번 선언이 되면 변수가 사용 가능한 영역을 벗어나도 메모리에 기억되어 사라지지 않는 변수를 말합니다.
static 변수를 선언하게 되면 다시 함수를 호출하여도 초기화가 되지 않고 지난 값들을 기억하고 있다가 다시 그 값을 불러들이게 됩니다.
정적 변수는 클래스의 모든 인스턴스 또는 객체 간에 값이 공유되는 변수입니다.
변수를 정적으로 정의하면 객체가 아닌 클래스에 연결됩니다. 정적 변수의 메모리는 클래스 로딩 시간 동안 할당됩니다.
https://www.tutorialspoint.com/where-and-how-to-use-static-variable-in-swift
https://varyeun.tistory.com/entry/%EC%8A%A4%EC%9C%84%ED%94%84%ED%8A%B8%EC%97%90%EC%84%
반응형
'iOS > Basic Study' 카테고리의 다른 글
Throw / try / do catch (0) | 2023.04.18 |
---|---|
escaping closure (0) | 2023.04.14 |
Completion handler (0) | 2023.04.06 |
iOS로드맵 / swiftUI (0) | 2023.01.12 |
App's Life Cycle 화면생명주기, AppDelegate, SceneDelegate (0) | 2022.12.15 |
Comments