Starbucks Caramel Frappuccino
본문 바로가기
  • 그래 그렇게 조금씩

SwiftUI107

19. Timer 타이머 ⭐️Timer 타이머⭐️ 지난 시간 컴바인 개념을 떠올리며.. 타이머도 Publisher이다. 일정한 시간 간격마다 이벤트를 생성하기 때문이다. 이를 활용해서 카운트 다운, 시계, 디데이, 애니메이션, 자동 스와이프 등을 구현할 수 있다. Timer let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect() every - 타이머 이벤트가 발생하는 간격 (여기서는 1초 마다) on - 타이머 이벤트가 실행되는 큐를 지정. (여기서는 UI 업데이트 관련 작업을 하기에 메인 스레드로 지정) in - 타이머 이벤트를 처리할 스케줄러(scheduler)를 지정. .common은 일반적인 실행 우선순위를 가짐. (타이머 이벤트가 기본 실행 우.. 2023. 6. 13.
18. Combine 컴바인 .feat JSON ⭐️Combine / 컴바인⭐️ 컴바인,RxSwift 말로는 참 많이 들었다. 드디어 찍먹을 해본다! https://developer.apple.com/documentation/combine Combine | Apple Developer Documentation Customize handling of asynchronous events by combining event-processing operators. developer.apple.com https://developer.apple.com/videos/play/wwdc2019/722/ Introducing Combine - WWDC19 - Videos - Apple Developer Combine is a unified declarative fram.. 2023. 6. 13.
17. JSON Download with @escaping ⭐️JSON Download with @escaping⭐️ 지난 시간에 이어 인터넷 url을 통해 json 데이터를 받아와보자. JSON 테스트 API https://jsonplaceholder.typicode.com/ JSONPlaceholder - Free Fake REST API {JSON} Placeholder Free fake API for testing and prototyping. Powered by JSON Server + LowDB. Tested with XV. Serving ~2 billion requests each month. jsonplaceholder.typicode.com api를 통해서 json을 받아올 때 활용할 수 있는 사이트. 이미지, 포스트 등 다양한 샘플이 존재함. .. 2023. 6. 12.
16. Codable, JSON, Encodable, Decodable ⭐️Codable, JSON⭐️ Codable 프로토콜을 통해 JSON 데이터를 인코딩, 디코딩 해보자. https://toughie-ios.tistory.com/113 JSON Parsing JSON이란? JavaScriptObjectNotation의 약자. JSON의 문법이 자바스크립트 문법과 유사하지만 자바스크립트에서만 사용되는 것이 아니라 JSON Parsing을 지원하는 프로그래밍 언어에서는 다 사용할 수 있다. toughie-ios.tistory.com 예전에 작성한 게시글을 한 번 훑고 시작하기. - JSON은 데이터 교환을 위한 가벼운 데이터 형식 - Encoding은 특정 데이터를 JSON으로 변환 - Decoding은 JSON 데이터를 필요한 데이터 형태로 변환(보통 JSON Parsi.. 2023. 6. 12.
15. mask 마스킹 ⭐️mask 마스킹⭐️ 마스킹 테이프.. 피그마의 마스크와 같이 SwiftUI에서도 마스크 기능을 사용할 수 있다. 별점 등록 뷰를 만들어 보고 마스크 없이 했을 때와, 마스크를 썼을 때 할 수 있는 것과 차이점을 알아보자. // Created by Toughie on 2023/05/26. // import SwiftUI struct starRating: View { @State var rating = 0 var body: some View { HStack { ForEach(1..= index ? Color.yellow : Color.gray) .onTapGesture { withAnimation(.spring()) { rating = index } } } } } } 사실 시중 앱에서 별점을 매길 때 애.. 2023. 5. 26.
14. sheet 시트 사용법 / multiple sheets ⭐️sheet 시트 사용법 / multiple sheets⭐️ 한 화면에서 여러가지 다른 종류의 시트(모달)를 띄우는 경우 의도한 대로 적절한 시트가 띄워지지 않는 문제를 겪을 수 있다. // Created by Toughie on 2023/05/25. // import SwiftUI struct SheetModel: Identifiable { let id = UUID().uuidString let title: String } struct MultipleSheetsPrac: View { @State var selectedModel: SheetModel = SheetModel(title: "START") @State var showSheet: Bool = false var body: some View { .. 2023. 5. 25.