Wednesday, July 22, 2026
HomeiOS Developmentios - Replace Storyboard UI After Retrieving Contacts

ios – Replace Storyboard UI After Retrieving Contacts

[ad_1]

I’m engaged on an app that may begin out by requesting entry to the customers contacts after which show details about the primary contact within the UI.

    func requestContactsAccess() {
    let retailer = CNContactStore()
    retailer.requestAccess(for: .contacts, completionHandler: {_,_ in })
    
    DispatchQueue.predominant.async {
        let authorizationStatus = CNContactStore.authorizationStatus(for: .contacts)
        
        if authorizationStatus == .approved {
            self.retrieveContacts()
            self.updateScreen()
        } else {
            self.alert()
        }
    }

The issue I’m working into is that the UI tries to replace earlier than the app will get person permission to entry the contacts. I attempted to get round this by utilizing a completion handler to name the perform to replace the UI after fetching the contacts however this causes the error when updating my label “UILabel.textual content should be used from predominant thread solely”

TLDR: How can I guarantee I’ve retrieved the gadget contacts earlier than updating the UI?

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments