DispatchQueue asyncAfter do the trick too
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: {
NSAlert.init(error: ...... ).runModal() }
Seems the problem is in the delay.
Post
Replies
Boosts
Views
Activity
Hello,
I found a solution to workaround that bug :
call runModal() in a function called from perform(#selector...) like this :
@objc func displayAlert(error: NSError)
{
NSAlert.init(error: error).runModal()
}
self.perform(#selector(self.displayAlert), with: NSError, afterDelay: 0.3, inModes: [RunLoop.Mode.common])
Hope this will help you.
I have the same error with this simple code :
DispatchQueue.global().async {
// some code
DispatchQueue.main.async {
// some code
NSAlert.init(error: ...... ).runModal()
}
}
The answer given by the apple employee here https://developer.apple.com/forums/thread/88825 do not fix the problem.
I am using Xcode 13.3 with macOS 12.3
These 2 methods :
"data(from:documentAttributes:)" and "init(data:options:documentAttributes:)"
must be executed on main thread otherwise you have a crash or sometimes random data are inserted in you result (Data or NSAttributedString) (random bug)
For macOS too (not only for ios as the apple employee wrongly said).
The documentation said execution on main thread must be done for documenType .html.
The execution must be done on main thread for plaintext, rtf and html (all documentType) not only html as it is wrongly written.
I spent enough time on that issue.
This is a bug (10.15.7 catalina, xcode 12.2)
Same here
After a crash on documentation on xcode 12.0 ( https://developer.apple.com/forums/thread/660490 ) they provided a fix with 12.0.1, and now for downloading it (who must normally be updated automatically like Brave, Opera or other modern applications) it is done @ 1 to 3 KB/s on Apple store.
Congratulations Apple !
You can download it here with normal speed (Xcode 12.1 GM seed ) : https://developer.apple.com/download/more
What a calamity, they are at their 12th version of the development tool in 20 years counting project builder and at each version they say: "Improved stability" and we are now at more than 30GB to download because of a crash when we ask for the documentation. Yes to just ask for documentation. We don't count the 3 or 4 tasks in parallel at 100% cpu usage each on machines producing teraflops power just to check the Swift syntax. This is the clearest illustration of Peter's complex. In fact, the more apple earns money the more their products degrade. I know this because I follow them from NeXT computer. And I'm not talking about their disastrous reactivity, drowning in bureaucracy like a mammoth.
I fact the code is correct. I was simply comment some lines (add the key )between 2 runs to avoid errors in debug mode.
By simply modify the code it triggers the non-availability of the key. For example reverse 2 lines :
change :
											 kSecAttrKeyClass: kSecAttrKeyClassSymmetric,
											 kSecAttrLabel: name] as [CFString : Any]
by
												kSecAttrLabel: name] as [CFString : Any],
												kSecAttrKeyClass: kSecAttrKeyClassSymmetric
Which is the same thing.
By doing that the key is more available.(no value for kSecValueData)
The same thing happened with kSecClassGenericPassword but a prompt ask the keychain password.
The problem is that for symmetric key there is no prompt and the key is not accessible (no value for kSecValueData)
Loosing the key by that way is too dangerous.
How can i get the key stored ?
Note: This does not happened with playground.
You can modify the code at will and the key is always retrieved.
Thank you.
> What’s the relationship between these processes?Nothing, just 2 debug run.i run SecItemAdd and SecItemCopyMatching, it works (i get the key)i run only SecItemCopyMatching and i don't get the key (kSecValueData missing). but the key is stored.i do that in debug mode.