Post

Replies

Boosts

Views

Activity

What is a reliable way, to check user system locale is using 12-hours or 24-hours format?
We would like to know, whether a user system locale is using 12-hours or 24-hours format? There are many proposed solutions at https://stackoverflow.com/q/1929958/72437 One of the solutions are let formatString = DateFormatter.dateFormat(fromTemplate: "j", options: 0, locale: Locale.current)! let hasAMPM = formatString.contains("a") However, to me, this is not a correct solution. When I tested with de_DE (German is using 24-hours), the returned string is HH 'Uhr' What is Uhr mean for? I guess it mean "clock" in German? There are so many other locales and one of them might contain letter a. Does anyone know, what is a correct way, to check whether user system locale is using 12-hours or 24-hours format?
3
0
963
Feb ’23
Does anyone know how can we edit "Data Not Linked to You" only?
My app starts to introduce AdMob. In App Store Connect page, when I perform editing under App Privacy/ Data Types The input choice will be applicable to both "Data Used to Track You" and "Data Not Linked to You" Does anyone know how we can only edit "Data Not Linked to You" only? Am I doing something not right? Also, I notice that I am not allow to uncheck "Device ID" and then submit (For testing purpose). Is it because I am using NSUserTrackingUsageDescription in my app?
0
0
1.1k
Jan ’23
SwiftUI - How to get correct RGB value from theme aware named color?
The following is a code example from widget extension. By using .environment(.colorScheme, ...), I am able to update view with correct theme aware named color. However, I am not able to retrieve the correct RGB value, from the theme aware named color. private func getColorScheme() -> ColorScheme { if ... { return ColorScheme.dark } else { return ColorScheme.light } } @ViewBuilder func contentView() -> some View { // Light/ dark theme aware let color = SwiftUI.Color("yellowNoteColor") calculate(color) HStack { ... } .background(color) .environment(\.colorScheme, getColorScheme()) } func calculate(_ color: SwiftUI.Color) { var a: CGFloat = 0.0 var r: CGFloat = 0.0 var g: CGFloat = 0.0 var b: CGFloat = 0.0 let uiColor = UIColor(self) uiColor.getRed(&r, green: &g, blue: &b, alpha: &a) // !!! Always get the light theme color value !!! } Inside calculate function, the retrieved value is always in the light theme color value. My guess is, caculate function is executed before .environment(\.colorScheme, getColorScheme()), that's why we are getting light theme color value always. May I know, how to get correct RGB value from theme aware named color?
0
0
1.1k
Dec ’22
Is calling WidgetCenter.shared.reloadAllTimelines() everytime during sceneDidEnterBackground a good practice?
Our widget extension appearance, is dependent on the main app content. The only way for us to keep the widget(s) up-to-date, is to perform the following during app inactive. class SceneDelegate: UIResponder, UIWindowSceneDelegate { func sceneDidEnterBackground(_ scene: UIScene) { // Refresh home widgets. WidgetCenter.shared.reloadAllTimelines() This is always called regardless whether there is widget being placed. I was wondering, is this consider a good practice? I do not wish to perform unnecessary operation, which will drain up user battery.
0
1
1k
Dec ’22
How to avoid CoreData corruption when developing Share extension to CoreData in AppGroup?
We plan to develop a Share extension. The CoreData is storing its SQLite file in AppGroup folder. The share extension will run in a different process than main app's. Since share extension and main app are running in different process, both will have their own instance of CoreData. However, even there are multiple instances of CoreData in different processes, their underlying are pointing to a single same SQLite file. Under https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW1 It mentions When you set up a shared container, the containing app—and each contained app extension that you allow to participate in data sharing—have read and write access to the shared container. To avoid data corruption, you must synchronize data accesses. Use Core Data, SQLite, or Posix locks to help coordinate data access in a shared container. But it isn't clear, what are detailed steps required to How can we synchronize access to CoreData among 2 processes? Who should responsible to consume relevant store change, and update the single token file? (https://developer.apple.com/documentation/coredata/consuming_relevant_store_changes) Should it be main app, share extension or both? Thank you.
1
0
951
Nov ’22
Is there any static analysis tool which can help us detect memory leak cause by missing [weak self]?
I was wondering, is there any tool, which can help to detect memory leak caused by missing [weak self]. For instance, the following code contains memory leak issue caused by lack of [weak self] class ImagePageViewController: UIPageViewController { lazy var memoryLeak = UIAction( title: "memory_leak", image: nil ) { _ in print(">>>> \(self)") } } Is there any tool which can help us to prevent such issue? I have tried  https://github.com/realm/SwiftLint but it is not able to detect such.
1
0
730
Sep ’22
Why the show/ hide table view mechanism doesn't work in non iPhone SE simulator?
I am using the following mechanism, to perform UITableView's row show and hide. class TableViewController: UITableViewController { private var hiddenIndexPaths : Set<IndexPath> = [] override func viewDidLoad() { super.viewDidLoad() } @IBAction func toggle(_ sender: UISwitch) { if sender.isOn { show(1) show(2) } else { hide(1) hide(2) } tableView.beginUpdates() tableView.endUpdates() } private func isHidden(_ indexPath: IndexPath) -> Bool { hiddenIndexPaths.contains(indexPath) } private func hide(_ item: Int) { hiddenIndexPaths.insert(IndexPath(item: item, section: 0)) } private func show(_ item: Int) { hiddenIndexPaths.remove(IndexPath(item: item, section: 0)) } override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { if isHidden(indexPath) { return 0.0 } return super.tableView(tableView, heightForRowAt: indexPath) } } As you can see, it works great in iPhone SE simulator (Works well in iPhone SE real device too) iPhone SE simulator linkText However, in non iPhone SE simulator (Like iPhone 13), once the table row is hidden, it can no longer be shown. Please refer to the following video. iPhone 13 simulator I am not sure what will its behavior in iPhone 13 real device, because I do not have access. I was wondering, do you have any idea why such issue occurs? If you are interested to test, here's the complete workable sample - https://github.com/yccheok/show-hide-table-row-bug
Topic: UI Frameworks SubTopic: UIKit Tags:
4
0
1.2k
Sep ’22
Why SFSymbol "face.smiling" will changed to "face.smiling.fill" when switching to dark mode.
I am using XCode 14. The following is the UIImageView, using SFSymbol face.smiling UIImageView background is pink color UIImageView tint is black color When I switch my app to dark mode, the smiling face which use to be transparent color, has became solid black color. The face line (eye, mouth, face border) used to be solid black color, had became transparent color. It seems like the image has changed from "face.smiling" to "face.smiling.fill" ? I would like to avoid such outcome. Is there a way, to force UIImageView load SFSymbol in light mode, even though the entire app is using dark mode? (This happens same when I test using real device and simulator) Thanks.
Topic: Design SubTopic: General Tags:
2
1
2.1k
Sep ’22
Stability of XCode 14
My XCode 13+ was used at MacBook Pro (13-inch, M1, 2020, 16G RAM) without issue Even since updated XCode to 14 week ago, I experience slowness while typing in XCode, and other editing operation. and, this crash happens few times a day Does anyone experience the same thing as I do? Thanks.
1
0
692
Sep ’22
CoreData generated class - Is there memory leak risk of not using weak in inverse relationship?
When come to circular reference, it comes with risk of memory leaking, by not using a weakkeyword. For instance :- Memory leak without using weak class Human { deinit { print("bye bye from Human") } init(_ pet: Pet) { self.pet = pet } let pet: Pet } class Pet { deinit { print("bye bye from Pet") } var human: Human? } print("start of scope") if true { let pet = Pet() let human = Human(pet) pet.human = human print("going to end of scope") } print("end of scope") /* Output: start of scope going to end of scope end of scope */ No memory leak by using weak class Human { deinit { print("bye bye from Human") } init(_ pet: Pet) { self.pet = pet } let pet: Pet } class Pet { deinit { print("bye bye from Pet") } weak var human: Human? } print("start of scope") if true { let pet = Pet() let human = Human(pet) pet.human = human print("going to end of scope") } print("end of scope") /* Output: start of scope going to end of scope bye bye from Human bye bye from Pet end of scope */ In CoreData, when setup 2 entities with one-to-many relationship, it is recommended to have inverse relationship too. Hence, CoreData will generate the following class with circular reference. extension NSHolidayCountry { @nonobjc public class func fetchRequest() -> NSFetchRequest<NSHolidayCountry> { return NSFetchRequest<NSHolidayCountry>(entityName: "NSHolidayCountry") } @NSManaged public var code: String @NSManaged public var name: String @NSManaged public var holidaySubdivisions: NSOrderedSet } extension NSHolidaySubdivision { @nonobjc public class func fetchRequest() -> NSFetchRequest<NSHolidaySubdivision> { return NSFetchRequest<NSHolidaySubdivision>(entityName: "NSHolidaySubdivision") } @NSManaged public var code: String @NSManaged public var name: String @NSManaged public var holidayCountry: NSHolidayCountry? } NSHolidaySubdivision is having inverse relationship to NSHolidayCountry. However, such inverse relationship is not marked as weak, based on CoreData generated class. I was wondering, does this come with a memory leak risk? Should I, add a weak keyword manually in entity NSHolidaySubdivision's holidayCountry ?
0
0
715
Sep ’22
Is there any special handling required in StoreKit2, to handle promo code redemption?
My users will redeem promo code via app store (outside my app) Currently, I am using StoreKit2 to Query Transaction.currentEntitlements during app startup Keep listening to Transaction.updates I was wondering, is that is so, is there any special code required, to handle Promo code redeem from user? I guess by keep listening to Transaction.updates, will able to handle such case? But, I am not able to test that, without rolling out my app to production. Thanks.
1
0
837
Sep ’22
Can anyone share your experience in migrating CloudKit enabled CoreData to AppGroup to support Widget?
Our current app is using CloudKit enabled CoreData. Recently, we want to support Widget feature. We understand that in order to support Widget feature, we need to place our CoreData under AppGroup, so that the data can be accessed by Widget. May I know, is there any good guideline on how to do so, so that we would not cause data loss for existing users? Thank you.
0
0
637
Sep ’22
PHPickerConfiguration will produce wrong ordering sometimes during multi selection.
We notice PHPickerConfiguration will produce wrong ordering sometimes, during multi selection. Our app is targeting iOS 15, and the test is run on simulator iOS 15.5 Here the video to demonstrate the issue https://youtu.be/RrhqFuB2kqs Please note that, the standing cat picture suppose to be the 4th order. By looking at the console and UI outcome, it is mistakenly returned as 3rd order. Here's the code which show func chooseImage() { var configuration = PHPickerConfiguration() configuration.selectionLimit = 0 // https://developer.apple.com/documentation/photokit/phpickerconfiguration/selection configuration.selection = .ordered // GIF exclusion is still not supported - https://developer.apple.com/forums/thread/687415 configuration.filter = .images let picker = PHPickerViewController(configuration: configuration) picker.delegate = self present(picker, animated: true) } and here's the code which prints out the ordering of images. extension NewNoteViewController: PHPickerViewControllerDelegate { func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) { picker.dismiss(animated: true) guard !results.isEmpty else { return } var displayErrorOnce = false for result in results { result.itemProvider.loadFileRepresentation(forTypeIdentifier: UTType.image.identifier) { [weak self] (url, error) in precondition(!Thread.isMainThread) guard let self = self else { return } guard let url = url else { return } print(">>>> url \(url)") // ... } } } } This problem happens randomly. May I know, is there any workaround for this issue? Thank you.
Topic: UI Frameworks SubTopic: UIKit Tags:
0
0
692
Aug ’22
The longer we use CloudKit enabled CoreData, will it take longer time to sync a fresh new device?
After using CloudKit enabled CoreData app for a while, I have the following observation. I have been actively use a CloudKit enabled CoreData app, for 2 weeks. Then, I get another fresh device. Once I hook up the fresh device to internet, based on the UI updating sequence, it seems like CoreData is replaying the entire transaction history, starting from 2 weeks ago till now. So, my questions is, if we are using the CloudKit enabled CoreData app for 5 years. Then, when I get a fresh new device, will the CoreData replaying the entire transaction history starting from 5 years ago? Isn't that is highly inefficient, and cause the new device sync extremely slow? Is that is so, how can we avoid such slowness, when user is using the app long time enough, and then decide to sync to a newly bought device? Thank you
0
1
656
Jul ’22
How should we handle history tracking transactions purging, if we allow users to enable/ disable CloudKit sync?
Due to privacy concern, we wish to provide a toggle switch, so that user has the freedom, to choose whether to sync CoreData with iCloud. We can implement such a feature by following suggestion from https://developer.apple.com/forums/thread/118924?login=true However, we should not perform history tracking transactions purging, once user disables CloudKit sync Reason is that, if few months later/ few years later, user decides to turn on CloudKit sync again, lack of sufficient history tracking transactions, will cause CloudKit sync fail. This is causing a dilemma. If we never clean the history tracking transactions, will it cause disk full issue? If that is so, may I know, what is the correct way to handle history tracking transactions purging, if we allow users to enable/ disable CloudKit sync? Thank you.
0
0
754
Jun ’22
What is a reliable way, to check user system locale is using 12-hours or 24-hours format?
We would like to know, whether a user system locale is using 12-hours or 24-hours format? There are many proposed solutions at https://stackoverflow.com/q/1929958/72437 One of the solutions are let formatString = DateFormatter.dateFormat(fromTemplate: "j", options: 0, locale: Locale.current)! let hasAMPM = formatString.contains("a") However, to me, this is not a correct solution. When I tested with de_DE (German is using 24-hours), the returned string is HH 'Uhr' What is Uhr mean for? I guess it mean "clock" in German? There are so many other locales and one of them might contain letter a. Does anyone know, what is a correct way, to check whether user system locale is using 12-hours or 24-hours format?
Replies
3
Boosts
0
Views
963
Activity
Feb ’23
Does anyone know how can we edit "Data Not Linked to You" only?
My app starts to introduce AdMob. In App Store Connect page, when I perform editing under App Privacy/ Data Types The input choice will be applicable to both "Data Used to Track You" and "Data Not Linked to You" Does anyone know how we can only edit "Data Not Linked to You" only? Am I doing something not right? Also, I notice that I am not allow to uncheck "Device ID" and then submit (For testing purpose). Is it because I am using NSUserTrackingUsageDescription in my app?
Replies
0
Boosts
0
Views
1.1k
Activity
Jan ’23
SwiftUI - How to get correct RGB value from theme aware named color?
The following is a code example from widget extension. By using .environment(.colorScheme, ...), I am able to update view with correct theme aware named color. However, I am not able to retrieve the correct RGB value, from the theme aware named color. private func getColorScheme() -> ColorScheme { if ... { return ColorScheme.dark } else { return ColorScheme.light } } @ViewBuilder func contentView() -> some View { // Light/ dark theme aware let color = SwiftUI.Color("yellowNoteColor") calculate(color) HStack { ... } .background(color) .environment(\.colorScheme, getColorScheme()) } func calculate(_ color: SwiftUI.Color) { var a: CGFloat = 0.0 var r: CGFloat = 0.0 var g: CGFloat = 0.0 var b: CGFloat = 0.0 let uiColor = UIColor(self) uiColor.getRed(&r, green: &g, blue: &b, alpha: &a) // !!! Always get the light theme color value !!! } Inside calculate function, the retrieved value is always in the light theme color value. My guess is, caculate function is executed before .environment(\.colorScheme, getColorScheme()), that's why we are getting light theme color value always. May I know, how to get correct RGB value from theme aware named color?
Replies
0
Boosts
0
Views
1.1k
Activity
Dec ’22
Is calling WidgetCenter.shared.reloadAllTimelines() everytime during sceneDidEnterBackground a good practice?
Our widget extension appearance, is dependent on the main app content. The only way for us to keep the widget(s) up-to-date, is to perform the following during app inactive. class SceneDelegate: UIResponder, UIWindowSceneDelegate { func sceneDidEnterBackground(_ scene: UIScene) { // Refresh home widgets. WidgetCenter.shared.reloadAllTimelines() This is always called regardless whether there is widget being placed. I was wondering, is this consider a good practice? I do not wish to perform unnecessary operation, which will drain up user battery.
Replies
0
Boosts
1
Views
1k
Activity
Dec ’22
How to avoid CoreData corruption when developing Share extension to CoreData in AppGroup?
We plan to develop a Share extension. The CoreData is storing its SQLite file in AppGroup folder. The share extension will run in a different process than main app's. Since share extension and main app are running in different process, both will have their own instance of CoreData. However, even there are multiple instances of CoreData in different processes, their underlying are pointing to a single same SQLite file. Under https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW1 It mentions When you set up a shared container, the containing app—and each contained app extension that you allow to participate in data sharing—have read and write access to the shared container. To avoid data corruption, you must synchronize data accesses. Use Core Data, SQLite, or Posix locks to help coordinate data access in a shared container. But it isn't clear, what are detailed steps required to How can we synchronize access to CoreData among 2 processes? Who should responsible to consume relevant store change, and update the single token file? (https://developer.apple.com/documentation/coredata/consuming_relevant_store_changes) Should it be main app, share extension or both? Thank you.
Replies
1
Boosts
0
Views
951
Activity
Nov ’22
Is there any static analysis tool which can help us detect memory leak cause by missing [weak self]?
I was wondering, is there any tool, which can help to detect memory leak caused by missing [weak self]. For instance, the following code contains memory leak issue caused by lack of [weak self] class ImagePageViewController: UIPageViewController { lazy var memoryLeak = UIAction( title: "memory_leak", image: nil ) { _ in print(">>>> \(self)") } } Is there any tool which can help us to prevent such issue? I have tried  https://github.com/realm/SwiftLint but it is not able to detect such.
Replies
1
Boosts
0
Views
730
Activity
Sep ’22
Why the show/ hide table view mechanism doesn't work in non iPhone SE simulator?
I am using the following mechanism, to perform UITableView's row show and hide. class TableViewController: UITableViewController { private var hiddenIndexPaths : Set<IndexPath> = [] override func viewDidLoad() { super.viewDidLoad() } @IBAction func toggle(_ sender: UISwitch) { if sender.isOn { show(1) show(2) } else { hide(1) hide(2) } tableView.beginUpdates() tableView.endUpdates() } private func isHidden(_ indexPath: IndexPath) -> Bool { hiddenIndexPaths.contains(indexPath) } private func hide(_ item: Int) { hiddenIndexPaths.insert(IndexPath(item: item, section: 0)) } private func show(_ item: Int) { hiddenIndexPaths.remove(IndexPath(item: item, section: 0)) } override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { if isHidden(indexPath) { return 0.0 } return super.tableView(tableView, heightForRowAt: indexPath) } } As you can see, it works great in iPhone SE simulator (Works well in iPhone SE real device too) iPhone SE simulator linkText However, in non iPhone SE simulator (Like iPhone 13), once the table row is hidden, it can no longer be shown. Please refer to the following video. iPhone 13 simulator I am not sure what will its behavior in iPhone 13 real device, because I do not have access. I was wondering, do you have any idea why such issue occurs? If you are interested to test, here's the complete workable sample - https://github.com/yccheok/show-hide-table-row-bug
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
4
Boosts
0
Views
1.2k
Activity
Sep ’22
Why SFSymbol "face.smiling" will changed to "face.smiling.fill" when switching to dark mode.
I am using XCode 14. The following is the UIImageView, using SFSymbol face.smiling UIImageView background is pink color UIImageView tint is black color When I switch my app to dark mode, the smiling face which use to be transparent color, has became solid black color. The face line (eye, mouth, face border) used to be solid black color, had became transparent color. It seems like the image has changed from "face.smiling" to "face.smiling.fill" ? I would like to avoid such outcome. Is there a way, to force UIImageView load SFSymbol in light mode, even though the entire app is using dark mode? (This happens same when I test using real device and simulator) Thanks.
Topic: Design SubTopic: General Tags:
Replies
2
Boosts
1
Views
2.1k
Activity
Sep ’22
Stability of XCode 14
My XCode 13+ was used at MacBook Pro (13-inch, M1, 2020, 16G RAM) without issue Even since updated XCode to 14 week ago, I experience slowness while typing in XCode, and other editing operation. and, this crash happens few times a day Does anyone experience the same thing as I do? Thanks.
Replies
1
Boosts
0
Views
692
Activity
Sep ’22
CoreData generated class - Is there memory leak risk of not using weak in inverse relationship?
When come to circular reference, it comes with risk of memory leaking, by not using a weakkeyword. For instance :- Memory leak without using weak class Human { deinit { print("bye bye from Human") } init(_ pet: Pet) { self.pet = pet } let pet: Pet } class Pet { deinit { print("bye bye from Pet") } var human: Human? } print("start of scope") if true { let pet = Pet() let human = Human(pet) pet.human = human print("going to end of scope") } print("end of scope") /* Output: start of scope going to end of scope end of scope */ No memory leak by using weak class Human { deinit { print("bye bye from Human") } init(_ pet: Pet) { self.pet = pet } let pet: Pet } class Pet { deinit { print("bye bye from Pet") } weak var human: Human? } print("start of scope") if true { let pet = Pet() let human = Human(pet) pet.human = human print("going to end of scope") } print("end of scope") /* Output: start of scope going to end of scope bye bye from Human bye bye from Pet end of scope */ In CoreData, when setup 2 entities with one-to-many relationship, it is recommended to have inverse relationship too. Hence, CoreData will generate the following class with circular reference. extension NSHolidayCountry { @nonobjc public class func fetchRequest() -> NSFetchRequest<NSHolidayCountry> { return NSFetchRequest<NSHolidayCountry>(entityName: "NSHolidayCountry") } @NSManaged public var code: String @NSManaged public var name: String @NSManaged public var holidaySubdivisions: NSOrderedSet } extension NSHolidaySubdivision { @nonobjc public class func fetchRequest() -> NSFetchRequest<NSHolidaySubdivision> { return NSFetchRequest<NSHolidaySubdivision>(entityName: "NSHolidaySubdivision") } @NSManaged public var code: String @NSManaged public var name: String @NSManaged public var holidayCountry: NSHolidayCountry? } NSHolidaySubdivision is having inverse relationship to NSHolidayCountry. However, such inverse relationship is not marked as weak, based on CoreData generated class. I was wondering, does this come with a memory leak risk? Should I, add a weak keyword manually in entity NSHolidaySubdivision's holidayCountry ?
Replies
0
Boosts
0
Views
715
Activity
Sep ’22
Is there any special handling required in StoreKit2, to handle promo code redemption?
My users will redeem promo code via app store (outside my app) Currently, I am using StoreKit2 to Query Transaction.currentEntitlements during app startup Keep listening to Transaction.updates I was wondering, is that is so, is there any special code required, to handle Promo code redeem from user? I guess by keep listening to Transaction.updates, will able to handle such case? But, I am not able to test that, without rolling out my app to production. Thanks.
Replies
1
Boosts
0
Views
837
Activity
Sep ’22
Can anyone share your experience in migrating CloudKit enabled CoreData to AppGroup to support Widget?
Our current app is using CloudKit enabled CoreData. Recently, we want to support Widget feature. We understand that in order to support Widget feature, we need to place our CoreData under AppGroup, so that the data can be accessed by Widget. May I know, is there any good guideline on how to do so, so that we would not cause data loss for existing users? Thank you.
Replies
0
Boosts
0
Views
637
Activity
Sep ’22
PHPickerConfiguration will produce wrong ordering sometimes during multi selection.
We notice PHPickerConfiguration will produce wrong ordering sometimes, during multi selection. Our app is targeting iOS 15, and the test is run on simulator iOS 15.5 Here the video to demonstrate the issue https://youtu.be/RrhqFuB2kqs Please note that, the standing cat picture suppose to be the 4th order. By looking at the console and UI outcome, it is mistakenly returned as 3rd order. Here's the code which show func chooseImage() { var configuration = PHPickerConfiguration() configuration.selectionLimit = 0 // https://developer.apple.com/documentation/photokit/phpickerconfiguration/selection configuration.selection = .ordered // GIF exclusion is still not supported - https://developer.apple.com/forums/thread/687415 configuration.filter = .images let picker = PHPickerViewController(configuration: configuration) picker.delegate = self present(picker, animated: true) } and here's the code which prints out the ordering of images. extension NewNoteViewController: PHPickerViewControllerDelegate { func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) { picker.dismiss(animated: true) guard !results.isEmpty else { return } var displayErrorOnce = false for result in results { result.itemProvider.loadFileRepresentation(forTypeIdentifier: UTType.image.identifier) { [weak self] (url, error) in precondition(!Thread.isMainThread) guard let self = self else { return } guard let url = url else { return } print(">>>> url \(url)") // ... } } } } This problem happens randomly. May I know, is there any workaround for this issue? Thank you.
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
0
Boosts
0
Views
692
Activity
Aug ’22
The longer we use CloudKit enabled CoreData, will it take longer time to sync a fresh new device?
After using CloudKit enabled CoreData app for a while, I have the following observation. I have been actively use a CloudKit enabled CoreData app, for 2 weeks. Then, I get another fresh device. Once I hook up the fresh device to internet, based on the UI updating sequence, it seems like CoreData is replaying the entire transaction history, starting from 2 weeks ago till now. So, my questions is, if we are using the CloudKit enabled CoreData app for 5 years. Then, when I get a fresh new device, will the CoreData replaying the entire transaction history starting from 5 years ago? Isn't that is highly inefficient, and cause the new device sync extremely slow? Is that is so, how can we avoid such slowness, when user is using the app long time enough, and then decide to sync to a newly bought device? Thank you
Replies
0
Boosts
1
Views
656
Activity
Jul ’22
How should we handle history tracking transactions purging, if we allow users to enable/ disable CloudKit sync?
Due to privacy concern, we wish to provide a toggle switch, so that user has the freedom, to choose whether to sync CoreData with iCloud. We can implement such a feature by following suggestion from https://developer.apple.com/forums/thread/118924?login=true However, we should not perform history tracking transactions purging, once user disables CloudKit sync Reason is that, if few months later/ few years later, user decides to turn on CloudKit sync again, lack of sufficient history tracking transactions, will cause CloudKit sync fail. This is causing a dilemma. If we never clean the history tracking transactions, will it cause disk full issue? If that is so, may I know, what is the correct way to handle history tracking transactions purging, if we allow users to enable/ disable CloudKit sync? Thank you.
Replies
0
Boosts
0
Views
754
Activity
Jun ’22