|
hello! i use a navigationBarButton to request a fetch of the contatcs stored in the device. in general it's working, but when the database is big (like on my real device) it blocks the fetchReuest button (it blocks the whole UI!). at the request i use DisppatchQueue.main.async, but still no improvement. do you have an idea, what i am doing wrong? all my code is still on trial basis, so not all is nicely done yet. thanks in advance for your support and help!
|
|
Hey I know this is a little late but I've recently needed to support the Contacts framework and created a very SwiftUI-friendly API that matches what you find when using Apple's own CoreData APIs. As such, I'm posting this here in case it helps you or others. Its open source so feel free to use in your personal or commercial apps :) Example:
|
|
@shaps80 I am trying to use your framework. I have a TabView and i only want to request access to contacts when tapping on the second tab. However, when I launch the app all i get is a white screen and it never asks me to access contacts unless i kill rhe app. I think it does this because the 2 tab having the @FetchContactList is called when the TabView loads. Not sure on that. How do i only request access when tapping the 2 tab with your framework? Any help would be appreciated. |
|
What you could do is to use tags and a state variable for your Tabs. https://www.hackingwithswift.com/books/ios-swiftui/creating-tabs-with-tabview-and-tabitem Then you could use the onChange modifier for your state and only call the method when Tab 2 is selected. |
SAVE 50% To celebrate WWDC22, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.