I wonder if I need to use Future to return data?
Post
Replies
Boosts
Views
Activity
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)
}
}
May I ask how I can receive a bool result in my view controller like
func validateUser(username: String?, password: String?) -> AnyPublisher<Bool, Never> {
if let username = username, let password = password {
if !username.isEmpty && !password.isEmpty {
// true
}
}
}
, please?
I don't know if my approach in reading view model data is correct. At least, I don't think it's efficient in the view controller.
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]))
}
}
}
Oops... Silly me... If it's logged in, I only show Text("Yes, I'm logged in")
Probably not because this EnvironmetValue is not dichotomous?
Are you talking about Apple's marketing resources??
Oh, I see. Silly me... Thanks a lot.
What I should have done is the following.
override func viewDidLoad() {
super.viewDidLoad()
cancellable = $segmentNumber.receive(on: DispatchQueue.main)
.sink(receiveValue: { (number) in
self.actionButton.isEnabled = (number == 0) ? false : true
})
}
Silly me...
I guess it's a dumb question. segmentNumber is not a bool object.
I guess I can use Internal Testing.
If you allow them to make a purchase, you do have to use the IAP system, I suppose. I don't know if children are allowed to use this type of apps, though. See if you are eligible for a commission waiver.
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?
I guess another good possibility is that Company A adds me to their team so that I can code-sign and then submit the app to the iTunes Connect server.