Post

Replies

Boosts

Views

Activity

Reply to Double value conversion issue
Double represents values in binary floating point system. So, every programming language may show the same results. One way would be showing the result with proper rounding. Another might be using Decimal instead of Double. But which would be better depends on your use case.
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’21
Reply to Calling an object.method as variables
If you want to apply some method dynamically, you may need something like perform(_:).         _ = (target as AnyObject?)?.perform(action) Please remember, Swift compiler cannot check if the target can respond to the selector target at compile time. Neither can check the number nor the types of the arguments. You should better consider using closures if you can touch the class definition.
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’21
Reply to Code
@Shikithita, Unless you are the author of the app, this is not a place to ask sort of code for TestFlight of some specific app. TestFlight apps are controlled by the authors of the apps, you should contact them.
Dec ’21
Reply to Cannot convert value of type 'ChooseModel.Angle' to expected argument type 'Angle'
My model like: Some lines missing. Is it a struct or a class? What is the type name? Cannot convert value of type 'ChooseModel.Angle' to expected argument type 'Angle' If you want to use SwiftUI.Angle, you should not define your own Angle. They have the same name but two different things. To make a struct Codable which contains SwiftUI.Angle, you need to make SwiftUI.Angle Codable, or add a conversion method to and from your own Angle and SwiftUI.Angle. By the way, you should better respond to all answers and comments you get, which helps you to get better answers sooner.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’21
Reply to Winzo app
This is not a place to request(?) an invitation code of some specific app. Contact to the author of the app.
Dec ’21
Reply to Run async tasks using Background Tasks
I'm misunderstanding something and/or doing something wrong As far as I see the documentation of setTaskCompleted(success:), it should be called when the task is completed. Have you tried something like this? private func configureBackgroundTasks() { Logger.log(.info, "Registering background tasks...") let bgTaskIdentifier = "com.example.task" BGTaskScheduler.shared.register(forTaskWithIdentifier: bgTaskIdentifier, using: DispatchQueue.main) { (task) in Logger.log(.info, "Performing background task \(bgTaskIdentifier)") Task { if let updatedData = await appManager.getUpdateAppData() { DispatchQueue.main.async { appManager.data = updatedData task.setTaskCompleted(success: true) } } else { task.setTaskCompleted(success: false) } backgroundTaskManager.scheduleAppRefresh() } } }
Topic: App & System Services SubTopic: Core OS Tags:
Dec ’21
Reply to Function Issue: Closure containing a declaration cannot be used with result builder 'ViewBuilder'
The declaration of function saveButtonPressed() resides in the body of body. You need to move it out of body. struct AddALandmarkForm: View { @Environment(\.presentationMode) var presentatoinMode @EnvironmentObject var listViewModel: ListViewModel @State var newLocationName: String = "" @State var texts: String = "Enter a Description" @State public var newPropertyType1 = false @State public var propertyPrice: String = "" @State var email: String = "" @State var ownerName: String = "" @State var alerTitle: String = "" @State var showAlert: Bool = false var body: some View { NavigationView { Form { //... } //<- End of `Form` .navigationBarTitle("Add a New Location") } //<- End of `NavigationView` } //<- End of `body` func saveButtonPressed() { listViewModel.addItem(title: newLocationName, descrip: texts, price: propertyPrice, mail: email, owner: ownerName) presentatoinMode.wrappedValue.dismiss() } } By the way, in Swift, type names should start with Capital letters. You should not use addALandmarkForm as a struct name in Swift.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’21
Reply to Double value conversion issue
Double represents values in binary floating point system. So, every programming language may show the same results. One way would be showing the result with proper rounding. Another might be using Decimal instead of Double. But which would be better depends on your use case.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Calling an object.method as variables
If you want to apply some method dynamically, you may need something like perform(_:).         _ = (target as AnyObject?)?.perform(action) Please remember, Swift compiler cannot check if the target can respond to the selector target at compile time. Neither can check the number nor the types of the arguments. You should better consider using closures if you can touch the class definition.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Code
@Shikithita, Unless you are the author of the app, this is not a place to ask sort of code for TestFlight of some specific app. TestFlight apps are controlled by the authors of the apps, you should contact them.
Replies
Boosts
Views
Activity
Dec ’21
Reply to Snapshot listener duplicating data
Can you tell us what is snapshot? I cannot find a method named addSnapshotListener in the Apple's frameworks.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to ISSUE: on iOS 15 the top and bottom banners are black instead of white. These need to be updated to a white background.
Can you create a minimized project that can reproduce the same issue and share the whole code?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Snapshot listener duplicating data
Thanks for clarifying. I have never worked with Firebase, so I am not sure, but your issue may be caused by the behavior of Firebase snapshot. You would get better responses sooner if you visit a site where more experienced developers of Firebase are watching.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Cannot convert value of type 'ChooseModel.Angle' to expected argument type 'Angle'
My model like: Some lines missing. Is it a struct or a class? What is the type name? Cannot convert value of type 'ChooseModel.Angle' to expected argument type 'Angle' If you want to use SwiftUI.Angle, you should not define your own Angle. They have the same name but two different things. To make a struct Codable which contains SwiftUI.Angle, you need to make SwiftUI.Angle Codable, or add a conversion method to and from your own Angle and SwiftUI.Angle. By the way, you should better respond to all answers and comments you get, which helps you to get better answers sooner.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Winzo app
This is not a place to request(?) an invitation code of some specific app. Contact to the author of the app.
Replies
Boosts
Views
Activity
Dec ’21
Reply to Run async tasks using Background Tasks
I'm misunderstanding something and/or doing something wrong As far as I see the documentation of setTaskCompleted(success:), it should be called when the task is completed. Have you tried something like this? private func configureBackgroundTasks() { Logger.log(.info, "Registering background tasks...") let bgTaskIdentifier = "com.example.task" BGTaskScheduler.shared.register(forTaskWithIdentifier: bgTaskIdentifier, using: DispatchQueue.main) { (task) in Logger.log(.info, "Performing background task \(bgTaskIdentifier)") Task { if let updatedData = await appManager.getUpdateAppData() { DispatchQueue.main.async { appManager.data = updatedData task.setTaskCompleted(success: true) } } else { task.setTaskCompleted(success: false) } backgroundTaskManager.scheduleAppRefresh() } } }
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Go back a few steps NavigationView SwiftUI
Can you share your code to go back to the original state?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Function Issue: Closure containing a declaration cannot be used with result builder 'ViewBuilder'
The declaration of function saveButtonPressed() resides in the body of body. You need to move it out of body. struct AddALandmarkForm: View { @Environment(\.presentationMode) var presentatoinMode @EnvironmentObject var listViewModel: ListViewModel @State var newLocationName: String = "" @State var texts: String = "Enter a Description" @State public var newPropertyType1 = false @State public var propertyPrice: String = "" @State var email: String = "" @State var ownerName: String = "" @State var alerTitle: String = "" @State var showAlert: Bool = false var body: some View { NavigationView { Form { //... } //<- End of `Form` .navigationBarTitle("Add a New Location") } //<- End of `NavigationView` } //<- End of `body` func saveButtonPressed() { listViewModel.addItem(title: newLocationName, descrip: texts, price: propertyPrice, mail: email, owner: ownerName) presentatoinMode.wrappedValue.dismiss() } } By the way, in Swift, type names should start with Capital letters. You should not use addALandmarkForm as a struct name in Swift.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Optional somehow becomes nil after passing through a condition to prevent that
You should better avoid forced something. Can you try something like this and tell us what you get? .onAppear { if let song = Bundle.main.url(forResource: "01", withExtension: "mp3") { do { self.player = try AVAudioPlayer(contentsOf: song) } catch { print(error) } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Using protocol functions at unknown class
What do you want to achieve? For almost all the code using NSClassFromString, there would be more Swifty and better ways.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Gfortran
Working with open source like gfortran is not an active topic in the dev forums. You should better find a better place to get better responses sooner.
Replies
Boosts
Views
Activity
Dec ’21
Reply to Using protocol functions at unknown class
How many classes? Thousands or more?
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Dec ’21