Post

Replies

Boosts

Views

Activity

Reply to Problem with sleep() code
Why is that? Because sleep uses seconds. And 0.9 is rounded to zero. Use asleep instead, with number in micro seconds usleep(900000) UILabel! text is not updated on each iteration, but only after entire loop has completed. You need to execute in another thread and then update in the main thread with a dispatchQueue So correct code would be: @IBOutlet weak var accuracyLabel: UILabel! // I find it better to declare at beginning of class override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) DispatchQueue.global().async { // Dispatch to another thread for percent in 1...10 { print(percent) DispatchQueue.main.async { // to update UI, go back to main thread self.accuracyLabel.text = "\(percent)" + "%" } usleep(900000) // do it in other thread, never on main thread } } Tell if you have other problem. Otherwise, don't forget to close the thread. Good continuation.
Topic: UI Frameworks SubTopic: UIKit Tags:
Apr ’21
Reply to Dynamic Localization
What do you want exactly with Dynamic Localization ? add a new language programmatically ? select the language from the app, directly ? If you want to localise 'on the fly': https://developer.apple.com/forums/thread/129946
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to Assistant not opening the correct swift file
@Rocky48  You are confusing a lot of things and you should probably start learning the basics of Interface Builder. You can have storyboard(s) and xib. For instance the storyboard for all the ViewControllers and additional xib for cells definitions or for other ViewControllers that you want to instantiate by yourself in code. So, storyboard don't prevent having xib as well, but VC that are in storyboard have not an independent xib (at least not one directly visible in Xcode).
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to Assistant not opening the correct swift file
I think everybody above was trying to make the problem too complicated, whereas the solution was so simple if you are an expert you do not think of the simplest solution, but overkill the question when it is staring you in the face. Problem is also that some beginners do not follow the advices that are given: If you have only storyboard opened: select the VC in IB Assistant command should open the file.swift Assistant command means to everyone with minimal practice "the menu command". That was clearly not enough for you. Have a good day.
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to What does 'Extra arguments at positions in call' mean?
It means you pass 7 arguments where your func signature hase only 3. OOPer correction should likely make it work. However, passing an array for sectionData sectionData: [productName, listingPrice, briefDescription, productURL, activeUntil] Where the item nature (name, price, …) depend on the position in the array is not robust. If you mix order, for whatever reason, you'll get messy display. You could use a dictionary instead: let sectionDict = ["name": productName, "price": listingPrice, "brief": briefDescription, "url": productURL, "until": activeUntil] Then when you use in the cell, you call sectionDict["brief"] ?? "" if brief exists, you get it otherwise you have an empty string. But no risk to display price in place for brief.
Topic: UI Frameworks SubTopic: UIKit Tags:
Apr ’21
Reply to Need help with Swift 4.2
@DikkeBana  Without more code and details on what you get and what you expect, it is pretty hard to tell where the error is. So I need to guess: the update occurs in a loop the frame is updated only at the end of loop Is it exact ? If so, you need to: execute in another thread and return to main thread for updating the frame. See my answer for a similar issue in this other thread: https://developer.apple.com/forums/thread/678507
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’21
Reply to Cannot find 'application' in scope
Looks like you have the same problem in another thread btnCallClick() func was empty. And you had callNumber() func not called anywhere So you have probably messed up things. To solve: disconnect the button (in IB) : click on the small x in front of the IBAction name reconnect to the IBAction btnCallClick do an option-clean build folder to clean everything
Topic: Programming Languages SubTopic: Swift Tags:
Apr ’21
Reply to how do i make a call from a button
@Richard_Klug Where exactly do you crash ? What crash log do you get ? There is something curious in your code: callButtonClicked is an empty func @IBAction func callButtonClicked(_ sender: Any) { } In addition, callNumber() func is not called anywhere… Notes: if the sender is a button, it is better to use UIButton type as sender instead of Any. it is not a good practice on the forum to use another thread (even more when it is 4 years old) to ask an additional question. Open a new thread and if needed paste a reference to the older thread.
Topic: UI Frameworks SubTopic: UIKit Tags:
Apr ’21
Reply to Local Notification
Just tried this, it didn’t work. Other ideas? No other idea if you don't give other information. Could you explain precisely what you get, what you expect, conditions of test… And please, show the complete code where you tried it. Or is it the same code than the other thread ? https://developer.apple.com/forums/thread/671702 Don't forget to close the threads when you're done or explain what is still not working as expected.
Apr ’21