전체 글
-
[SwiftUI] Navigator with NavigationStack, PopoupView카테고리 없음 2023. 11. 26. 12:58
import SwiftUI import PopupView struct ContentView: View { @StateObject var navigator = Navigator() var body: some View { NavigationStack { VStack { Button("show detail") { navigator.route(NavigationItem.detail) } Button("show setting") { navigator.route(NavigationItem.setting) } Button("show popup") { navigator.route(PopupItem.default) } Button("show") { navigator.route(BottomsheetItem.default)..
-
[SwiftUI] NavigationStackSwift/SwiftUI 2023. 11. 26. 12:28
import SwiftUI struct ContentView: View { @State var destination: Destination? var body: some View { NavigationStack { Button("Append") { destination = .detail } .navigationDestination(item: $destination, destination: { destination in switch destination { case .detail: Color.green case .setting: Color.red } }) } } } enum Destination { case detail case setting } #Preview { ContentView() }
-
[UIKit] BottomButton Keyboard + Combine + SnapKitSwift/UIKit 2023. 11. 5. 00:54
import SnapKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() hideKeyboardWhenTappedAround() NotificationCenter.default.publisher(for: UIResponder.keyboardWillShowNotification) .receive(on: DispatchQueue.main) .sink { notification in let info = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue let keyboardHeight = info?.cgRect..
-
[Swift] @dynamicMemberLookup 써보기Swift 2023. 10. 26. 16:06
GitHub - insub4067/Hello--dynamicMemberLookup Contribute to insub4067/Hello--dynamicMemberLookup development by creating an account on GitHub. github.com @dynamicMemberLookup struct Model { var items: [String: String] subscript(dynamicMember key: String) -> String? { items[key] } } struct Parent { let id: Int let name: String } @dynamicMemberLookup struct Child { let name: String let parent: Par..
-
[Swift] KeyPath, WritableKeyPath, ReferenceWritableKeyPath 차이와 구분해서 사용하기Swift 2023. 10. 25. 17:55
GitHub - insub4067/KeyPath--WritableKeyPath--ReferenceWritableKeyPath Contribute to insub4067/KeyPath--WritableKeyPath--ReferenceWritableKeyPath development by creating an account on GitHub. github.com protocol SelfReturnable { associatedtype ReturnType func with(_ keyPath: WritableKeyPath, _ value: T) -> ReturnType } extension SelfReturnable { func with(_ keyPath: WritableKeyPath, _ value: T) -..
-
[Swift] NSPredicate format placeholdersSwift 2023. 10. 25. 16:59
format placeholders 정리에 대한 GPT 의 답변 In Objective-C, when creating an NSPredicate with a format string, you can use several different placeholders to represent values of different data types. Here are some common placeholders for format strings in NSPredicate: 1. %@: Used for representing object values, such as NSString, NSNumber, NSDate, and other NSObject-derived classes. 2. %K: Used for specif..
-
[Combine] AsyncPublisher 란?Swift 2023. 10. 24. 13:42
struct ContentView: View { @StateObject var viewModel = ContentViewModel() var body: some View { Button("Button") { viewModel.didTap() } } } class ContentViewModel: ObservableObject { @Published var items: [String] = [] private var store = Set() init() { observe() } func didTap() { items = ["1", "2", "3"] } func observe() { Task { for await value in $items.values { print("values: ", value) } } $..