Post

Replies

Boosts

Views

Activity

Reply to Observing Changes in Multiple @Published Variables at the Same Time?
I think I've figured it out for myself. It looks like I can use Publishers.CombineLatest(,) as follows. class ViewController: UIViewController { var cancellables = Set<AnyCancellable>() @Published var userText: String = "" @Published var passText: String = "" override func viewDidLoad() { super.viewDidLoad() NotificationCenter.default.publisher(for: UITextField.textDidChangeNotification, object: usernameTextField) .sink(receiveValue: { (result) in if let myField = result.object as? UITextField { if let text = myField.text { self.userText = text } } }) .store(in: &cancellables) NotificationCenter.default.publisher(for: UITextField.textDidChangeNotification, object: passwordTextField) .sink(receiveValue: { (result) in if let myField = result.object as? UITextField { if let text = myField.text { self.passText = text } } }) .store(in: &cancellables) Publishers.CombineLatest($userText, $passText) .sink { (result0, result1) in print(result0, result1) }.store(in: &cancellables) } }
Oct ’21
Reply to Updating @State Variable Depending ForEach Row Selection
It seems that I have achieved my objective with the following. But I'm not sure if it's an efficient approach. import SwiftUI struct ContentView: View { @State var numbers = [2021, 9, 30] var body: some View { let firstLocalYear = 2021 let firstLocalMonth = 9 let firstLocalDay = 24 let firstLastDay = 30 NavigationView { List { Section(header: Text("Current month")) { ForEach(firstLocalDay ..< firstLastDay) { i in HStack { Text("\(firstLocalMonth)-\(i + 1)") Spacer() Button("Select") { self.numbers = [firstLocalYear, firstLocalMonth, i + 1] } NavigationLink( destination: TimeView(numbers: $numbers), label: { Text("") }) } } } } } } } struct TimeView: View { @Binding var numbers: [Int] var body: some View { HStack { Text(String(numbers[0])) Text(String(numbers[1])) Text(String(numbers[2])) } } }
Sep ’21
Reply to Review process
We are trying to get an app on the App Store that uses background location management. According to the review team, our app is used solely for the purpose of tracking employees, and is thus unsuitable for the App Store. The guideline the review team says we do not follow is 2.5.4. And why does the app need to run in the background mode?
Jan ’21