Skip to content

Instantly share code, notes, and snippets.

@TuenTuenna
Created October 14, 2021 08:41
Show Gist options
  • Save TuenTuenna/f422c08de2c24a4c607ead9a4a0497d6 to your computer and use it in GitHub Desktop.
Save TuenTuenna/f422c08de2c24a4c607ead9a4a0497d6 to your computer and use it in GitHub Desktop.
SwiftUi 뷰에서 테스트 프린트 하는 법

SwiftUi 뷰에서 테스트 프린트 하는 법

View 익스텐션에 추가

  extension View {
    /// 프린트 출력 메소드
    func testPrint(_ vars: Any...) -> some View {
        for v in vars {
            print(v)
        }
        return EmptyView()
    }
}

사용 예시

struct ContentView: View {
    var body: some View {
        ScrollView{
            VStack(spacing: 50){
                Text("Hello, world!")
                    .padding()
                testPrint("하하하하")
                Button {
                    print("정대리 유튭 구독하기")
                } label: {
                    Text("구독 & 좋아요!")
                }
            }
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment