Post

Replies

Boosts

Views

Activity

Reply to Crash in Swift 6 when using UNUserNotification
@Engineer Thanks for reply. Some more crash info. On simulator (did not test on device at this stage). Here is crash report: Error occurs in #4 notifyMe IBAction @IBAction func notifyMe(_ sender: UIButton) { let center = UNUserNotificationCenter.current() center.delegate = self center.getNotificationSettings(completionHandler: { (settings) in if settings.authorizationStatus == .notDetermined { center.requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in DispatchQueue.main.async { if !granted { // Alert user } } } } else if settings.authorizationStatus == .denied { DispatchQueue.main.async { // Alert user } } else if settings.authorizationStatus == .authorized { DispatchQueue.main.async { self.alarmButton.isHidden = self.duree <= 120 } } }) var alertStyle = UIAlertController.Style.alert let alertController = UIAlertController( title: NSLocalizedString("M'avertir", comment: ""), message: NSLocalizedString("Attention", comment: ""), preferredStyle: alertStyle) var title = NSLocalizedString("5'", comment: "") let ok = UIAlertAction(title: title, style: .default, handler: {(action) -> Void in self.sendInitialNotification(beforeEnd: 5) DispatchQueue.main.async { sender.isHidden = true } }) alertController.addAction(ok) let cancelAction = UIAlertAction(title: NSLocalizedString("Non", comment: ""), style: .default, handler: { (action) -> Void in alertController.addAction(cancelAction) present(alertController, animated: true, completion: nil) } Crash apparently occurs on calling userNotificationCenter: nonisolated func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { if notification.request.identifier == requestIdentifier { completionHandler( [.alert,.sound,.badge]) } }
Aug ’25
Reply to Swift 6 conversion for IBOutlet
Thanks Quinn. I removed the nonisolated for IBOutlet. But, as shown in your example, I had to mark all func în a class that uses UNUserNotificationCenterDelegate as nonIsolated, such as nonisolated func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) I also note in your example that you marked response for didReceive as async. I tried to, but got the error: Instance method 'userNotificationCenter(_:didReceive:withCompletionHandler:)' nearly matches optional requirement 'userNotificationCenter(_:didReceive:withCompletionHandler:)' of protocol 'UNUserNotificationCenterDelegate' with the advice to Make 'userNotificationCenter_:didReceive:withCompletionHandler:)' private to silence this warning Converting to Swift 6 is definitely not an easy ride… I'll do extensive testing.
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’25
Reply to Crash in Swift 6 when using UNUserNotification
Thanks for the answer. didReceive was already non isolated. So problem likely does not come from here. For willPresent, if I don't make it nonIsolated, I get an Xcode 16.4 compiler error: Main actor-isolated instance method 'userNotificationCenter(_:willPresent:withCompletionHandler:)' cannot be used to satisfy nonisolated requirement from protocol 'UNUserNotificationCenterDelegate' n Xcode 26, no error in func declaration if I remove nonIsolated. But error at UIViewController class definition level Conformance of 'CalcViewController' to protocol 'UNUserNotificationCenterDelegate' crosses into main actor-isolated code and can cause data races
Aug ’25
Reply to Swift 6 conversion for IBOutlet
MainActor.assumeIsolated seems the simplest way to go. I have noticed an important point when converting to Swift 6 which may help others. At some point, I had nearly 200 errors… Don't panic they say… Problem was that errors kept coming and disappearing. Just as if the compiler was a bit lost (and me with him) with all the changes occurring on classes or func (such as declaring MainActor or non isolated). This made error correction pretty erratic. I did a Clean build folder, and the number of errors dropped to less than 10.
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’25
Reply to Range For Keys and Values Of Dictionary
You may build something custom. Just for illustration: typealias FruitDict = [String: (String, Int)] let myFruitBasket : FruitDict = ["apple":("red", 1), "banana": ("yellow", 2), "budbeeri": ("dark violet", 3), "chikoo": ("brown", 4)] func subBasket(_ basket: FruitDict, range: ClosedRange<Int>) -> [String: String] { let filtered = basket.filter { $0.value.1 >= range.lowerBound && $0.value.1 <= range.upperBound } let sub = filtered.mapValues{ value in value.0 } return sub } let sub: [String: String] = subBasket(myFruitBasket, range: 1...3) print(sub) print("keys: ", sub.keys) print("values", sub.values) You get: ["banana": "yellow", "apple": "red", "budbeeri": "dark violet"] keys: ["banana", "apple", "budbeeri"] values ["yellow", "red", "dark violet"] Of course, that's not ordered (order does not mean anything with dictionaries), as Quinn explained. But if you plan to use the result as a dictionary, that doesn't matter. To get ordered, you have to convert to array. Or you can compute: let sortedKeys = sub.keys.sorted() print("sorted keys: ", sortedKeys) for key in sortedKeys { print("sorted values", sub[key] ?? "") } And get sorted keys: ["apple", "banana", "budbeeri"] values red values yellow values dark violet
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’25
Reply to Using Dynamic Member Lookup in a Superclass
Interesting question (would like to see the solution), so my 1 cent contribution. Sorry if it is worthless. In The Swift Programming Language (Swift 5.7) : struct Point { var x, y: Int } @dynamicMemberLookup struct PassthroughWrapper<Value> { var value: Value subscript<T>(dynamicMember member: KeyPath<Value, T>) -> T { get { return value[keyPath: member] } } } let point = Point(x: 381, y: 431) let wrapper = PassthroughWrapper(value: point) print(wrapper.x) Have you tried to mimic this, by adding a value property in ElectronicComponent and calling PassthroughWrapper(value: resistorA) ?
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’25
Reply to Bug in Apple Developer Program License Agreement
No feedback. Closing the thread.
Replies
Boosts
Views
Activity
Aug ’25
Reply to Crash in Swift 6 when using UNUserNotification
@Engineer Thanks for reply. Some more crash info. On simulator (did not test on device at this stage). Here is crash report: Error occurs in #4 notifyMe IBAction @IBAction func notifyMe(_ sender: UIButton) { let center = UNUserNotificationCenter.current() center.delegate = self center.getNotificationSettings(completionHandler: { (settings) in if settings.authorizationStatus == .notDetermined { center.requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in DispatchQueue.main.async { if !granted { // Alert user } } } } else if settings.authorizationStatus == .denied { DispatchQueue.main.async { // Alert user } } else if settings.authorizationStatus == .authorized { DispatchQueue.main.async { self.alarmButton.isHidden = self.duree <= 120 } } }) var alertStyle = UIAlertController.Style.alert let alertController = UIAlertController( title: NSLocalizedString("M'avertir", comment: ""), message: NSLocalizedString("Attention", comment: ""), preferredStyle: alertStyle) var title = NSLocalizedString("5'", comment: "") let ok = UIAlertAction(title: title, style: .default, handler: {(action) -> Void in self.sendInitialNotification(beforeEnd: 5) DispatchQueue.main.async { sender.isHidden = true } }) alertController.addAction(ok) let cancelAction = UIAlertAction(title: NSLocalizedString("Non", comment: ""), style: .default, handler: { (action) -> Void in alertController.addAction(cancelAction) present(alertController, animated: true, completion: nil) } Crash apparently occurs on calling userNotificationCenter: nonisolated func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { if notification.request.identifier == requestIdentifier { completionHandler( [.alert,.sound,.badge]) } }
Replies
Boosts
Views
Activity
Aug ’25
Reply to Swift 6 conversion for IBOutlet
Thanks Quinn. I removed the nonisolated for IBOutlet. But, as shown in your example, I had to mark all func în a class that uses UNUserNotificationCenterDelegate as nonIsolated, such as nonisolated func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) I also note in your example that you marked response for didReceive as async. I tried to, but got the error: Instance method 'userNotificationCenter(_:didReceive:withCompletionHandler:)' nearly matches optional requirement 'userNotificationCenter(_:didReceive:withCompletionHandler:)' of protocol 'UNUserNotificationCenterDelegate' with the advice to Make 'userNotificationCenter_:didReceive:withCompletionHandler:)' private to silence this warning Converting to Swift 6 is definitely not an easy ride… I'll do extensive testing.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’25
Reply to Crash in Swift 6 when using UNUserNotification
Thanks for the answer. didReceive was already non isolated. So problem likely does not come from here. For willPresent, if I don't make it nonIsolated, I get an Xcode 16.4 compiler error: Main actor-isolated instance method 'userNotificationCenter(_:willPresent:withCompletionHandler:)' cannot be used to satisfy nonisolated requirement from protocol 'UNUserNotificationCenterDelegate' n Xcode 26, no error in func declaration if I remove nonIsolated. But error at UIViewController class definition level Conformance of 'CalcViewController' to protocol 'UNUserNotificationCenterDelegate' crosses into main actor-isolated code and can cause data races
Replies
Boosts
Views
Activity
Aug ’25
Reply to In Xcode 26 ß (iOS 26 simulator) UIBarButtonItem content disappear when tapped
Improved with Beta 4 and 5. Now, the text does not disappear when button is tapped, but is dimmed (like in disabled state). So I think it is the final version of UI.
Replies
Boosts
Views
Activity
Aug ’25
Reply to Swift 6 conversion for IBOutlet
MainActor.assumeIsolated seems the simplest way to go. I have noticed an important point when converting to Swift 6 which may help others. At some point, I had nearly 200 errors… Don't panic they say… Problem was that errors kept coming and disappearing. Just as if the compiler was a bit lost (and me with him) with all the changes occurring on classes or func (such as declaring MainActor or non isolated). This made error correction pretty erratic. I did a Clean build folder, and the number of errors dropped to less than 10.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’25
Reply to Using Dynamic Member Lookup in a Superclass
@reflexx Thanks for the feedback. Hope someone more expert will provide you with a $1 answer. 😉 Otherwise, don’t forget to close the thread. Have a good day.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’25
Reply to Swift 6 Minimum Requirement for App Store
That seems a reasonable guess. So it's time to prepare: https://wwdcnotes.com/documentation/wwdcnotes/wwdc24-10169-migrate-your-app-to-swift-6/
Replies
Boosts
Views
Activity
Aug ’25
Reply to Range For Keys and Values Of Dictionary
You may build something custom. Just for illustration: typealias FruitDict = [String: (String, Int)] let myFruitBasket : FruitDict = ["apple":("red", 1), "banana": ("yellow", 2), "budbeeri": ("dark violet", 3), "chikoo": ("brown", 4)] func subBasket(_ basket: FruitDict, range: ClosedRange<Int>) -> [String: String] { let filtered = basket.filter { $0.value.1 >= range.lowerBound && $0.value.1 <= range.upperBound } let sub = filtered.mapValues{ value in value.0 } return sub } let sub: [String: String] = subBasket(myFruitBasket, range: 1...3) print(sub) print("keys: ", sub.keys) print("values", sub.values) You get: ["banana": "yellow", "apple": "red", "budbeeri": "dark violet"] keys: ["banana", "apple", "budbeeri"] values ["yellow", "red", "dark violet"] Of course, that's not ordered (order does not mean anything with dictionaries), as Quinn explained. But if you plan to use the result as a dictionary, that doesn't matter. To get ordered, you have to convert to array. Or you can compute: let sortedKeys = sub.keys.sorted() print("sorted keys: ", sortedKeys) for key in sortedKeys { print("sorted values", sub[key] ?? "") } And get sorted keys: ["apple", "banana", "budbeeri"] values red values yellow values dark violet
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’25
Reply to Using Dynamic Member Lookup in a Superclass
Interesting question (would like to see the solution), so my 1 cent contribution. Sorry if it is worthless. In The Swift Programming Language (Swift 5.7) : struct Point { var x, y: Int } @dynamicMemberLookup struct PassthroughWrapper<Value> { var value: Value subscript<T>(dynamicMember member: KeyPath<Value, T>) -> T { get { return value[keyPath: member] } } } let point = Point(x: 381, y: 431) let wrapper = PassthroughWrapper(value: point) print(wrapper.x) Have you tried to mimic this, by adding a value property in ElectronicComponent and calling PassthroughWrapper(value: resistorA) ?
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’25
Reply to New App Submission - Current Wait Time Approaching a Month
Welcome to the forum. So your wait time is about 1 week 1/2, not a month… I suspect reviewer is specially cautious about this type of app and how it is moderated. IMHO that's a legitimate concern. As it too 2 weeks the first time, wait for a few more days. After that, if no news, you could contact support. PS: avoid to duplicate posts.
Replies
Boosts
Views
Activity
Aug ’25
Reply to Xcode error uploading to App store connect
You cannot upload with a beta version. That's exactly what the message was telling you. PS:Thanks for reporting it's solved. But would even be better to tell how.
Replies
Boosts
Views
Activity
Aug ’25
Reply to App Review Delay – Stuck in “Waiting for Review” for Several Days
I submitted several apps recently and it proceeded rapidly. I advise you NOT to remove the current build. I once did and it caused me issues. If nothing happen in the next 24 hours, you should contact support.
Replies
Boosts
Views
Activity
Jul ’25
Reply to Detecting iOS screen sharing
Could you detect the green dot that's close to the notch or in Dynamic Island ? But maybe the simplest is to check if camera is active: https://stackoverflow.com/questions/16460705/check-which-camera-is-currently-in-use-in-ios-application
Topic: Privacy & Security SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jul ’25