This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import SwiftUI | |
| import Vision // Text 뽑아오기 위한 import | |
| class ContentVM: ObservableObject { | |
| @Published public var isShowFullscreen = false // DocumentScan Full Flag | |
| @Published public var scanImages:[UIImage] = [UIImage]() // Scan Result Images | |
| // OCR Text,Rect 뺀 정보 (애니메이션을 위한 변수) | |
| @Published public var imageInfos:[JWScanTextItems] = [JWScanTextItems]() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import SwiftUI | |
| // Scan된 이미지에서 Text 및 rect 뽑아와서 담아주는 Model | |
| open class JWScanTextItems: Identifiable, ObservableObject { | |
| var uuid:String = UUID().uuidString // UUID 키값 | |
| var text:String = "" // 인식한 Text | |
| var rect:CGRect = .zero // Text Rect값 | |
| public init() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import SwiftUI | |
| class ContentVM: ObservableObject { | |
| @Published public var isShowFullscreen = false // DocumentScan Full Flag | |
| @Published public var scanImages:[UIImage] = [UIImage]() // Scan Result Images | |
| } | |
| struct ContentView: View { | |
| @StateObject var vm = ContentVM() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| 2023. 03. 17 Kimjiwook | |
| DocumentScan SwiftUI로 호출로직 구현 | |
| 아직은 SwiftUI 자체 제공이 없어서 UIKit으로 구현한 부분을 사용함. | |
| */ | |
| import SwiftUI | |
| import VisionKit | |
| //MARK: - #. DocumentSacn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // async, await 활용 | |
| // PHAsset -> 로컬다운로드 후 객체 관리 | |
| // 실행부 | |
| Task { | |
| do { | |
| // 로딩뷰 필요할것 같은데. | |
| self.listVM.event.loadingStart?() // 로딩 시작 (iCloud 받는 액션) | |
| // PHAsset -> DzAttachFile 전환 | |
| let files = try await self.getPHAssetIdToDzAttachFile(identifiers) | |
| self.listVM.event.loadingEnd?() // 로딩 종료 (iCloud 받는 액션) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// 1. async, awiat 구조 함수 (샘플로 인한 일부내용은 비공개) | |
| func asyncGetProtocol(mainUrl:String) async -> Result<[String:Any], NSError> { | |
| // [변환1] 함수부분 @escaping 클로져 제거 후 Retrun 형식 변환 | |
| // 네트워크 샘플 | |
| let url = "\(mainUrl)" | |
| // 파라메터 만들기 | |
| let param:Parameters = [ | |
| // ..(생략).. | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// 1. Call back 구조 함수 (샘플로 인한 일부내용은 비공개) | |
| func getProtocol(mainUrl:String, complete:@escaping doLoginComplete, fail:@escaping doLoginFail) { | |
| // 네트워크 샘플 | |
| let url = "\(mainUrl)" | |
| // 파라메터 만들기 | |
| let param:Parameters = [ | |
| // ..(생략).. | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| import Algorithms // 알고리즘 모듈 추가. | |
| class SampleVM: ObservableObject { | |
| let array:[String] = [ | |
| "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" | |
| ] | |
| init() { | |
| // 함수 호출해보기 | |
| print("[2개씩 나누기]") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| print("\n-- 3. Result Type Success, fail do Catch --\n") | |
| let repetition:[Bool] = [true, false] | |
| repetition.forEach({success in | |
| // Result Type 전달받을시 .get 성공시만 받고, 나머지는 예외케이스로 받게 처리가능 | |
| do { | |
| let response = try resultTypeSample(success: success).get() | |
| print(response) | |
| } catch (let error) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| print("\n-- 2. Result Type Success, fail Switch Case --\n") | |
| let repetition:[Bool] = [true, false] | |
| repetition.forEach({success in | |
| // Result Type 전달받을시 switch - case 문을 통해 | |
| // .success, .faulure Case로 로직처리 가능함 | |
| let result = resultTypeSample(success: success) | |
| switch result { | |
| case .success(let response): |