Post

Replies

Boosts

Views

Activity

Reply to Swift functions
i want to write this, Do you just want to write? No need to create an Array? so string and int What will be the values of the String and Int for the example output: [X, 0, 0, 0, 0] [0, X, 0, 0, 0] [0, 0, X, 0, 0] [0, 0, 0, X, 0]  The String value would be "X"? The Int value might be 4 (number of rows)? Or 5 (number of items in a row)? Or 0 (the value for non-X elements)? Or 20 (total number of items)? Or something else?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Is there a way of reloading a View Controller upon completion of a function?
Are there any functions which can be used to refresh it instead? What do you expect to happen with refresh? You may need to implement refresh() by yourself. Essentially all of the labels on my View Controller are assigned a database value, and when one of them are updated I need the View Controller to automatically update to reflect this new order of values.  You have some code somewhere to assign a database value to the labels, move them to refresh() and call it.
Topic: UI Frameworks SubTopic: UIKit Tags:
Apr ’21
Reply to Swift functions
Your function xos(item:count:) takes Int for item:. Your function call xos(item: xo, count: 1) is passing an Array (not Int) to item:. What sort of function do you want to write? A function taking Int and Int? Or a function taking Array and Int?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to When has the AVSpeechSynthesizer finished reading?
I do not understand what you are trying to do with your stillSpeaking. Generally, looping like while goingon ... does not make sense in GUI code. When you want to detect the AVSpeechSynthesizer finished reading, you implement speechSynthesizer(_:didFinish:) of AVSpeechSynthesizerDelegate. Please show all the relevant code, if you cannot make it by yourself.
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to In App Settings
Can you explain the steps to reproduce the behavior which you think is weird: Steps to reproduce What you expect with the steps What you actually get with the steps By the way, I can find many weird codings in your code shown: Home ViewController: static var riddleNotification = Bool() (26) -- Why using static? Why aren't you specifying the initial value explicitly? center.requestAuthorization (44) -- Why the completion handler is empty? func riddleNotification() { (50) -- Why making it nested inside viewDidLoad()? And better avoid the same name as property. else { (126) ... } (154) -- The else block would never be executed. Riddles(_:) (160), RiddlesandAnswers(_:) (174) -- Why using Capitalized names? Settings ViewController: leading_Settings (10), trailing_Settings (12) -- Why snake case? if Home.riddleNotification == true { (28) ... } (40) -- Why don't you write it simply riddleSwitch.setOn(Home.riddleNotification, animated: true)? if riddleSwitch.isOn { (84) ... } (100) -- Why don't you write it simply: 						Home.riddleNotification = riddleSwitch.isOn 						UDM.shared.defaults.setValue(riddleSwitch.isOn, forKey: "riddleNotification") And why do you have Home.riddleNotification and UserDefaults separately if they need to be synchronized to the same value? Some of them are just sort of convention things and may not be affecting your weird behavior, so you have no need to answer to all of the questions, but your code looks really weird for me.
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to healthkit query
You should better clarify that you are writing a native method interfaced to React Native. I really do not want to go deep into React Native, with 2 reasons: It is not a framework of Apple's. I do not like it You should better find an appropriate place to ask something about React Native. I just want to correct terrible mis-directions... which part of my code is in-correct Your code has two big flaws: JS.side and Swift code are inconsistent Your JS code calls updateStepsCount() with no arguments. But in your Swift code has a parameter before resolve. It represents that the JS side should pass one parameter. You call execute(query), but there is no code receive the result of query The result would never go into statisticsCollection without writing an explicit code to do so. But this problem should be resolved in another thread of yours. Issue #1 JS.side and Swift code are inconsistent I think you cannot create an instance of HKStatisticsCollection, which means you cannot pass a parameter to Swift method. Remove the first parameter of updateStepsCount: 		@objc 		func updateStepsCount(_	resolve: @escaping RCTPromiseResolveBlock, 													rejecter reject: @escaping RCTPromiseRejectBlock) { 				// Find the right code in another thread of yours... 		} Controller.m RCT_EXTERN_METHOD(updateStepsCount: (RCTPromiseResolveBlock)resolve 									rejecter: (RCTPromiseRejectBlock)reject)
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to Networking error management
I'm having this first issue: It is clear. You cannot throw from inside the completion handler of dataTask. The closure is called by iOS and iOS would never handle errors. You usually use (your own) completion handler to tell error to the caller, but in your case, adding a new @Published property holding the error would be an alternative. when I print the dataString Please show the core part of the dataString. And please show the settings of Postman when you get the right response. I guess you are not sending the same request in your code.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Thread 1: breakpoint 1.1 2.1
How do I solve? Better clarify solve what? This is my code: Please use Code block feature of this site (icon ``) when showing your code. I cannot get any messages like Thread 1: breakpoint 1.1 1.2 using the exact code you have shown. So the problem might exist in somewhere else in your project. Are you sure you have not added any breakpoint? Have really connected IBOutlets and IBActions correctly? Better try again creating a brand-new project, and copy the code, editing the storyboard again.
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21