-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Sobok-iOS/SobokSobok/SobokSobok/Service/Network/APIServices/Account/AddAccontAPI.swift
Lines 11 to 16 in 645498d
| public struct AddAccountAPI { | |
| static let shared = AddAccountAPI() | |
| var addAccountProvider = MoyaProvider<AddAccountService>() | |
| private init() { } |
구조체는 인스턴스를 공유하지 않습니다.
클래스의 경우 메모리를 가르키기 때문에(참조) 인스턴스를 공유하지만, 구조체는 value type 이기 때문에 값을 복사합니다.
만약, AddAccountAPI.shared 로 접근한다면, 값 변경이 이루어질 수 없을 뿐만 아니라 접근 할 때마다 다른 메모리를 보고있기 때문에 싱글톤이라고 보기 힘듭니다.
만약 싱글톤의 의미대로 인스턴스를 공유하며 주소를 공유하는 형태로 사용하려면 Class 를 사용하는게 좋아보입니다.
ref. https://hyerios.tistory.com/254
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels