Ray Wenderlich
-
Ch11. Lists & NavigationRay Wenderlich/SwiftUI 2021. 2. 7. 20:32
Ch11. Lists & Navigation Navigating through a SwiftUI app SwiftUI는 2가지 타입의 네비게이션을 제공한다. Flat - TabView를 사용 Hierarchical - NavigationView를 사용 Creating navigation views // 1 TabView { // 2 FlightBoard() // 3 .tabItem({ // 4 Image(systemName: "icloud.and.arrow.down") .resizable() Text("Arrivals") }) FlightBoard() .tabItem({ Image(systemName: "icloud.and.arrow.up") .resizable() Text("Departures") })..
-
Ch9. State & Data FlowRay Wenderlich/SwiftUI 2021. 2. 7. 20:26
Ch9. State & Data Flow SwiftUI는 많은 장점을 가지고 있는데 Declarative: View를 구현하지 않고 선언하는 방식으로 구현한다. Functional: 같은 State에서 항상 같은 UI 결과물을 갖는다. Reactive: State가 변경되면 SwiftUI가 자동으로 UI를 업데이트한다. State 이 책에서 @State라는 문법을 많이 봤다. var numberOfAnswered = 0 var numberOfQuestions = 5 var body: some View { // 1 Button(action: { // 2 self.numberOfAnswered += 1 }) { // 3 HStack { Text("\(numberOfAnswered)/\(numberOfQues..
-
Ch8. Introducint Stacks & ContainersRay Wenderlich/SwiftUI 2021. 2. 7. 20:20
Ch8. Introducint Stacks & Containers Layout for views with a single child struct ChallengeView: View { var body: some View { Text("Hello World!") .background(Color.red) } } Text("A great and warm welcome to Kuchi") .background(Color.red) SwiftUI가 ParentView와 ChildView의 사이즈를 결정하는 방식 Parent view가 생성될 때, 사용 가능한 프레임을 결정한다. Child view에게 이 프레임을 제안한다. Child view는 Parent view가 제안한 사이즈를 고려하여 자신의 사이즈를 결정한..
-
Ch7. Controls & User InputRay Wenderlich/SwiftUI 2021. 2. 7. 20:12
Ch7. Controls & User Input Power to the user: the TextField title과 text binding으로 생성할 수 있다. title: placeholder binding: textfield에 보이는 텍스트와 프로퍼티를 연결 @State var name: String = "" ... TextField("Type your name...", text: $name) Spacer VStack { Spacer() // Self.Body /// The content view type passed to `body()`. typealias Content } struct BorderedViewModifier: ViewModifier { func body(content: Conte..
-
Ch6. Intro to controls: Text & ImageRay Wenderlich/SwiftUI 2021. 2. 7. 20:08
Ch6. Intro to controls: Text & Image Are modifiers efficient? Modifier는 새로운 view를 리턴한다. 정말 이게 최선일까? Modifier는 사용될 때마다 뷰를 전달받아 새로운 뷰를 만든다. Recursive한 동작이 일어나는 것이다. Modifier를 연속적으로 호출하면 뷰 안에 뷰 안에 뷰 안에 뷰가 있는 그런 구조다. 마트료시카 인형처럼 말이다 언뜻보면 자원낭비처럼 보인다. 하지만 SwiftUI는 이 Stack을 효율적인 자료구조를 통해 flatten하여 뷰를 렌더링하고 있다. 그러니까 modifier를 마음껏 써도 된다. Text("Welcome to Kuchi") .background(Color.red) .padding() Text("Wel..
-
Ch3. Transforming OperatorsRay Wenderlich/Combine 2021. 1. 27. 20:26
collect() ["A", "B", "C", "D", "E"].publisher .collect() .sink(receiveCompletion: { print($0) }, receiveValue: { print($0) }) .store(in: &subscriptions) // collect에 parameter전달하여 메모리 과다사용 방지 ["A", "B", "C", "D", "E"].publisher.collect(3) .sink(receiveCompletion: { print($0) }, receiveValue: { print($0) }) .store(in: &subscriptions) ["A", "B", "C", "D", "E"] finished ["A", "B", "C"] ["D", "E"] fi..
-
Ch2. Publishers & SubscribersRay Wenderlich/Combine 2021. 1. 27. 20:23
Hello Publisher let myNotification = Notification.Name("MyNotification") let center = NotificationCenter.default let observer = center.addObserver(forName: myNotification, object: nil, queue: nil) { (notification) in print("Notification received!") } center.post(name: myNotification, object: nil) center.removeObserver(observer) Notification received! Hello Subscriber let myNotification = Notific..
-
Ch1. Hello, Combine!Ray Wenderlich/Combine 2021. 1. 27. 20:22
애플이 말했다. ‘The Combine framework provides a declarative approach for how your app processes events. Rather than potentially implementing multiple delegate callbacks or completion handler closures, you can create a single processing chain for a given event source. Each part of the chain is a Combine operator that performs a distinct action on the elements received from the previous step’'컴바인은 여러분의..