투케이2K

463. (ios/swift5) [OrderedDictionary] 딕셔너리 조작 라이브러리 사용해 containsKey 특정 key 포함 여부 확인 본문

IOS

463. (ios/swift5) [OrderedDictionary] 딕셔너리 조작 라이브러리 사용해 containsKey 특정 key 포함 여부 확인

투케이2K 2024. 4. 13. 12:07
반응형

[개발 환경 설정]

개발 툴 : XCODE

개발 언어 : SWIFT5

 

[소스 코드]

    // -----------------------------------------------------------------------------------------
    // MARK: - [테스트 메인 함수 정의 실시]
    // -----------------------------------------------------------------------------------------
    func testMain() {
        S_Log._D_(description: "테스트 함수 시작 실시", data: nil)
        
        
        /*
        // -------------------------------------------------------
        [요약 설명]
        // -------------------------------------------------------
        1. OrderedDictionary 라이브러리는 Ios 에서 간편하게 딕셔너리를 조작할 수 있는 라이브러리입니다
        // -------------------------------------------------------
        2. 필요 import : import OrderedDictionary
        // -------------------------------------------------------
        3. OrderedDictionary 라이브러리 Git 공식 사이트 : https://github.com/lukaskubanek/OrderedDictionary.git
        // -------------------------------------------------------
        4. OrderedDictionary 라이브러리 문법 참고 사이트 : https://github.com/apple/swift-collections/blob/main/Documentation/OrderedDictionary.md
        // -------------------------------------------------------
        5. 라이브러리 추가 방법 참고 사이트 : https://blog.naver.com/kkh0977/223414176473
        // -------------------------------------------------------
        */
        
        
        // [로직 처리 실시]
        DispatchQueue.main.async {
            
            // [초기 변수 선언]
            var dictionary: OrderedDictionary<String, Int> = [:]
            
            
            // [딕셔너리에 데이터 추가 수행]
            dictionary["one"] = 1
            dictionary["two"] = 2
            
            
            // [containsKey 특정 key 포함 확인]
            var oneFlag = dictionary.containsKey("one")
            var threeFlag = dictionary.containsKey("three")
            
            
            // [로그 출력 수행]
            S_Log._D_(description: "로그 출력 수행", data: [
                "oneFlag :: \(oneFlag)",
                "threeFlag :: \(threeFlag)"
            ])
            
        }

    }

[결과 출력]

 

 

반응형
Comments