투케이2K

540. (ios/swift5) [유틸 파일] goAppInnerFileShareIntent : 앱 내부 저장소 파일 공유 수행 본문

IOS

540. (ios/swift5) [유틸 파일] goAppInnerFileShareIntent : 앱 내부 저장소 파일 공유 수행

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

[개발 환경 설정]

개발 툴 : XCODE

개발 언어 : SWIFT5

 

[소스 코드]

    // -----------------------------------------------------------------------------------------
    // MARK: - [앱 내부 저장소 파일 공유 수행]
    // -----------------------------------------------------------------------------------------
    func goAppInnerFileShareIntent(_path : String) {
        
        /*
        // -----------------------------------------
        [goAppInnerFileShareIntent 메소드 설명]
        // -----------------------------------------
        1. 앱 내부 저장소 파일 공유 수행
        // -----------------------------------------
        2. 호출 예시 :
         
         let path = C_App().get_File_Url(folderName: "TEST_FOLDER", fileName: "test.txt")
         
         self.goAppInnerFileShareIntent(_path: path?.description ?? "")
        // -----------------------------------------
        3. 파일 경로 예시 :
         
         file:///var/mobile/Containers/Data/Application/106C..AAA1/Documents/LOG_FILE_FOLDER/TEST.txt
        // -----------------------------------------
        */
        
        // [메인 큐에서 비동기 방식 실행 : UI 동작 실시]
        DispatchQueue.main.async {
            
            // [사전 인풋 값 널 데이터 체크 수행 실시]
            if _path != nil && _path.count>0 && _path != "" {
                
                let activityItem:NSURL = NSURL(fileURLWithPath:_path)
                
                let activityVC = UIActivityViewController(activityItems: [activityItem], applicationActivities: nil)
                activityVC.popoverPresentationController?.sourceView = self.view
                
                self.present(activityVC, animated: true, completion: nil)
                
            }
            else {
                S_Log._F_(description: "앱 내부 파일 공유 인텐트 이동", data: [
                    "error :: 사전 인풋 데이터 체크 에러"
                ])

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

[결과 출력]

 
 

 

반응형
Comments