투케이2K

539. (ios/swift5) [유틸 파일] goTextSharedIntent : 텍스트 파일 공유 인텐트 이동 본문

IOS

539. (ios/swift5) [유틸 파일] goTextSharedIntent : 텍스트 파일 공유 인텐트 이동

투케이2K 2024. 8. 12. 20:29
반응형

[개발 환경 설정]

개발 툴 : XCODE

개발 언어 : SWIFT5

 

[소스 코드]

    // -----------------------------------------------------------------------------------------
    // MARK: - [텍스트 파일 공유 인텐트 이동]
    // -----------------------------------------------------------------------------------------
    func goTextSharedIntent(_string : String) {
        
        /*
        // -----------------------------------------
        [goTextSharedIntent 메소드 설명]
        // -----------------------------------------
        1. 텍스트 파일 공유 인텐트 이동
        // -----------------------------------------
        2. 호출 예시 : self.goTextSharedIntent(_string: "hello")
        // -----------------------------------------
        */
        
        // [메인 큐에서 비동기 방식 실행 : UI 동작 실시]
        DispatchQueue.main.async {
            
            // [사전 인풋 값 널 데이터 체크 수행 실시]
            if _string != nil && _string.count>0 && _string != "" {
                
                var shareText = [String]()
                shareText.append(_string)
                
                let activityVC = UIActivityViewController(activityItems: shareText, applicationActivities: nil)
                activityVC.popoverPresentationController?.sourceView = self.view
                
                self.present(activityVC, animated: true, completion: nil)
                
            }
            else {
                S_Log._F_(description: "텍스트 파일 공유 인텐트 이동", data: [
                    "error :: 사전 인풋 데이터 체크 에러"
                ])

                // [리턴 종료]
                return
            }
            
        }
    }
 

[결과 출력]

 
 

 

반응형
Comments