It's my first iOS app and I want to update ProgressView using while loop. I need help, It's not working says "UI element cannot be updated in background thread"
func update() {
DispatchQueue.global().async {
var current:Int = 0
let total = 100
while (current < total) {
current += 1
self.progress.setProgress(Float(current / total), animated: true)
self.text.text = "Hello: " + String(current)
print(Float(current / total))
sleep(UInt32(0.1))
}
}
}
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Why Swift is so complicated?
let current = 75, total = 100
let calc:Float = Float(current / total)
print(calc)
Expected result: 0.75
Console output: 0.0
"Your maximum App ID limit has been reached. You may create up to 10 App IDs every 7 days."
It's my day one, and I was practicing and learning the language. What to do now? I don't want to wait 🙄🧑🏻💻
Details
SendProcessControlEvent:toPid: encountered an error: Error Domain=com.apple.dt.deviceprocesscontrolservice Code=8 "Failed to show Widget 'WIDGET_PACKAGE_NAME' error: Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (WIDGET_PACKAGE_NAME)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (WIDGET_PACKAGE_NAME)}." UserInfo={NSLocalizedDescription=Failed to show Widget 'WIDGET_PACKAGE_NAME' error: Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (WIDGET_PACKAGE_NAME)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (WIDGET_PACKAGE_NAME)}., NSUnderlyingError=0x1029d5340 {Error Domain=SBAvocadoDebuggingControllerErrorDomain Code=1 "Failed to get descriptors for extensionBundleID (WIDGET_PACKAGE_NAME)" UserInfo={NSLocalizedDescription=Failed to get descriptors for extensionBundleID (WIDGET_PACKAGE_NAME)}}}
Domain: DTXMessage
Code: 1-
System Information
macOS Version 11.1 (Build 20C69)
Xcode 12.3 (17715) (Build 12C33)
Timestamp: 2021-01-18T12:30:29+05:30
UPDATE
I restarted my iPhone and it worked. Reported this as a bug.
I'm trying to create a widget and following this "wOrkcdeui4U" youtube tutorial and this - https://github.com/gfiocco/swiftui-widget-sample GitHub page.
Everything is set but the text is not visible it's just a grey rectangle. Have a look here. - https://www.icloud.com/iclouddrive/0psDv6X2UW2VwSCjGHk_nOJKw#Simulator_Screen_Shot_-_iPhone_12_mini_-_2021-01-18_at_15.40
I've one widget in my app, so technically I have two Targets.
Now every time I hit compile, Xcode just launching my widget's Target by default, not my app's Target and I can't even change the log to my app's Target instead of widget's Target. So I cannot read logs from ViewController.swift.
my app's Target
com.myapp my widget's Target
com.myapp.widget Help me. How can I add my primary Target there?
Multiple commands produce '/Users/arghadipdas/Library/Developer/Xcode/DerivedData/Widgets-dfmrjoounhtpfncpqalteomwmppi/Build/Intermediates.noindex/Widgets.build/Debug-iphonesimulator/Widgets.build/Objects-normal/x86_64/ConfigurationIntent.o':
1) Target 'Widgets' (project 'Widgets') has compile command for Swift source files
2) Target 'Widgets' (project 'Widgets') has compile command for Swift source files
I'm designing an image of a MacBook Pro and I need to know that which font-face is being used in 2020 MacBook Pro's keyboard (Magic Keyboard).
(I'm asking about the printed font-face on the magic keyboards)
Thanks.
Accidentally posted question on developer forums.