Posts

Post not yet marked as solved
1 Replies
454 Views
I'm introducing some SwiftUI into a primarily UIKit app and have noticed that, as soon as a SwiftUI view is presented / pushed to the nav stack in its hosting view controller, the memory graph shows a number of Swift closure context (unknown layout) entries under an <unknown> header. These entries persist after the SwiftUI view has been popped from the navigation stack. Is this cause for concern? I don't think it represents a memory leak within my app, because the entries are grouped under <unknown> as opposed to my app name. But I'm not entirely sure why they exist (and crucially, why they persist). It's possible to observe this behaviour with a really simple demo app. Just push the following view: struct ViewController02: View { var body: some View { Text("Hello, world!") } } onto a navigation stack: self.navigationController?.pushViewController(UIHostingController(rootView: ViewController02()), animated: true) Any advice / guidance / reassurance would be much appreciated. There can be a considerable number of these entries but I can't see how I could be causing a retain cycle.
Posted Last updated
.
Post not yet marked as solved
0 Replies
482 Views
Hi there, There might be something obvious I'm overlooking, but I can't for the life of me figure it out. Any help or guidance would be much appreciated! I've enabled push notifications for one of my app identifiers (developer portal and provisioning profile appear to be correct, as does the entitlements file). On a simulator, when I call registerForRemoteNotifications(), I immediately get a callback from didRegisterForRemoteNotificationsWithDeviceToken. However, when I run my app on any of my physical devices, this method is never called. Nor is didFailToRegisterForRemoteNotificationsWithError. If I manually remove the aps-environment key and deploy to my device, then didFailToRegisterForRemoteNotificationsWithError is invoked with an expected error message. Any idea what I may have done wrong here? I'm using Xcode 15.0.1 and have tried an iPhone 12 (iOS 15.5) and iPhone 13 Pro Max (iOS 16.7.2). My development environment requires a VPN, but I've tried disabling the VPN in case that was an issue. I've also tried restarting the devices and toggling Wi-Fi, airplane mode, etc. My app does integrate with Firebase (not FCM though), but I added the FirebaseAppDelegateProxyEnabled NO option, just in case (this wouldn't explain why it works on Simulator though). Thanks for your help!
Posted Last updated
.
Post marked as solved
1 Replies
543 Views
I'm currently adding support for different locales in my app, and one of the things I need to do is let folks input a valid decimal number. In order to do this I'm using a NumberFormatter with some specific settings: numberFormatter.locale = .current numberFormatter.maximumFractionDigits = 2 numberFormatter.minimumFractionDigits = 2 numberFormatter.numberStyle = .decimal numberFormatter.roundingMode = .halfEven numberFormatter.usesGroupingSeparator = true When the locale is set to en-GB or en-US, everything works fine. I'm successfully able to output values as strings, and then use the same number formatter to parse the string back into an NSNumber. However, if the locale is for a region where spaces are used as a grouping separator, everything breaks. The number formatter will happily output a value like 1 234.56 via string(from:), but it will fail to parse that exact string as a number using number(from:). After digging a bit deeper I discovered that, if I create a locale that uses spaces as the grouping separator and check: numberFormatter.groupingSeparator The output will be a 0x202f character (NARROW NO-BREAK SPACE). If I use that same number formatter to output a string value, the space it inserts in 1 000,00 is actually 0xa0. I think this is why the number formatter's output can't be parsed as valid input, but I'm not sure how to work around this situation. I ideally need to be able to parse "prettified" values that users have entered in their own locale, so I can't just set the number formatter to always use , as the grouping separator for example. Any advice would be much appreciated!
Posted Last updated
.