This is a dedicated space for developers to connect, share ideas, collaborate, and ask questions. Introduce yourself, network with other developers, and join us in fostering a supportive community.

All subtopics
Posts under Community topic

Post

Replies

Boosts

Views

Activity

Displaying limited contacts list in UIKit
I have an app that was written in UIKit. It's too large, and it would be much too time consuming at this point to convert it to SwiftUI. I want to incorporate the new limited contacts into this app. The way it's currently written everything works fine except for showing the limited contacts in the contact picker. I have downloaded and gone though the Apple tutorial app but I'm having trouble thinking it through into UIKit. After a couple of hours I decided I need help. I understand I need to pull the contact IDs of the contacts that are in the limited contacts list. Not sure how to do that or how to get it to display in the picker. Any help would be greatly appreciated. func requestAccess(completionHandler: @escaping (_ accessGranted: Bool) -> Void) { switch CNContactStore.authorizationStatus(for: .contacts) { case .authorized: completionHandler(true) case .denied: showSettingsAlert(completionHandler) case .restricted, .notDetermined: CNContactStore().requestAccess(for: .contacts) { granted, error in if granted { completionHandler(true) } else { DispatchQueue.main.async { [weak self] in self?.showSettingsAlert(completionHandler) } } } // iOS 18 only case .limited: completionHandler(true) @unknown default: break } } // A text field that displays the name of the chosen contact @IBAction func contact_Fld_Tapped(_ sender: TextField_Designable) { sender.resignFirstResponder() // The contact ID that is saved to the Db getTheCurrentContactID() let theAlert = UIAlertController(title: K.Titles.chooseAContact, message: nil, preferredStyle: .actionSheet) // Create a new contact let addContact = UIAlertAction(title: K.Titles.newContact, style: .default) { [weak self] _ in self?.requestAccess { _ in let openContact = CNContact() let vc = CNContactViewController(forNewContact: openContact) vc.delegate = self // this delegate CNContactViewControllerDelegate DispatchQueue.main.async { self?.present(UINavigationController(rootViewController: vc), animated: true) } } } let getContact = UIAlertAction(title: K.Titles.fromContacts, style: .default) { [weak self] _ in self?.requestAccess { _ in self?.contactPicker.delegate = self DispatchQueue.main.async { self?.present(self!.contactPicker, animated: true) } } } let editBtn = UIAlertAction(title: K.Titles.editContact, style: .default) { [weak self] _ in self?.requestAccess { _ in let store = CNContactStore() var vc = CNContactViewController() do { let descriptor = CNContactViewController.descriptorForRequiredKeys() let editContact = try store.unifiedContact(withIdentifier: self!.oldContactID, keysToFetch: [descriptor]) vc = CNContactViewController(for: editContact) } catch { print("Getting contact to edit failed: \(self!.VC_String) \(error)") } vc.delegate = self // delegate for CNContactViewControllerDelegate self?.navigationController?.isNavigationBarHidden = false self?.navigationController?.navigationItem.hidesBackButton = false self?.navigationController?.pushViewController(vc, animated: true) } } let cancel = UIAlertAction(title: K.Titles.cancel, style: .cancel) { _ in } if oldContactID.isEmpty { editBtn.isEnabled = false } theAlert.addAction(getContact) // Select from contacts theAlert.addAction(addContact) // Create new contact theAlert.addAction(editBtn) // Edit this contact theAlert.addAction(cancel) let popOver = theAlert.popoverPresentationController popOver?.sourceView = sender popOver?.sourceRect = sender.bounds popOver?.permittedArrowDirections = .any present(theAlert,animated: true) } func requestAccess(completionHandler: @escaping (_ accessGranted: Bool) -> Void) { switch CNContactStore.authorizationStatus(for: .contacts) { case .authorized: completionHandler(true) case .denied: showSettingsAlert(completionHandler) case .restricted, .notDetermined: CNContactStore().requestAccess(for: .contacts) { granted, error in if granted { completionHandler(true) } else { DispatchQueue.main.async { [weak self] in self?.showSettingsAlert(completionHandler) } } } // iOS 18 only case .limited: completionHandler(true) @unknown default: break } } // MARK: - Contact Picker Delegate extension AddEdit_Quote_VC: CNContactPickerDelegate { func contactPicker(_ picker: CNContactPickerViewController, didSelect contact: CNContact) { selectedContactID = contact.identifier let company: String = contact.organizationName let companyText = company == "" ? K.Titles.noCompanyName : contact.organizationName contactNameFld_Outlet.text = CNContactFormatter.string(from: contact, style: .fullName)! companyFld_Outlet.text = companyText save_Array[0] = K.AppFacing.true_App setSaveBtn_AEQuote() } } extension AddEdit_Quote_VC: CNContactViewControllerDelegate { func contactViewController(_ viewController: CNContactViewController, shouldPerformDefaultActionFor property: CNContactProperty) -> Bool { return false } func contactViewController(_ viewController: CNContactViewController, didCompleteWith contact: CNContact?) { selectedContactID = contact?.identifier ?? "" if selectedContactID != "" { let company: String = contact?.organizationName ?? "" let companyText = company == "" ? K.Titles.noCompanyName : contact!.organizationName contactNameFld_Outlet.text = CNContactFormatter.string(from: contact!, style: .fullName) companyFld_Outlet.text = companyText getTheCurrentContactID() if selectedContactID != oldContactID { save_Array[0] = K.AppFacing.true_App setSaveBtn_AEQuote() } } dismiss(animated: true, completion: nil) } }
2
0
790
Jun ’25
multidatepicker and saving multiple dates via swiftdata
Any help will be greatly appreciated. Trying to build a calendar/planner app for public school teachers. Classes are held on multiple dates so there is a need for swiftdata to save multiple dates. There are lots of tutorials demonstrating a multidatepicker but none of the tutorials or videos save the dates, via swiftdata. My goal is to save multiple dates. Step 1 is to initialize mockdata; this is done a class called ToDo. var dates:Set = [] Step 2 is the view containing a multidatepicker and other essential code Step 3 is to save multiple dates using swiftdata. Lots of tutorials, code snippets and help using a single date. But after almost 2 weeks of researching youtube tutorials, and google searches, I have not found an answer on how to save multiple dates via swiftdata. Also, I don't know how how to initialize the array of for the mockdata. Here are some code snippets used but the initialization of the array of DateComponenets doesnt work. And saving multiple dates doesn't work either @MainActor @Model class ToDo { var dates:Set<DateComponents> = [] init(dates: Set<DateComponents> = []) { self.dates = dates } } //view struct DetailView: View { @State var dates: Set<DateComponents> = [] @Environment(\.modelContext) var modelContext @State var toDo: ToDo @State private var dates: Set<DateComponents> = [] MultiDatePicker("Dates", selection: $dates) .frame(height: 100) .onAppear() { dates = toDo.dates } Button("Save") { //move data from local variables to ToDo object toDo.dates = dates //save data modelContext.insert(toDo) } } } #Preview { DetailView(toDo: ToDo()) .modelContainer(for: ToDo.self, inMemory: true) }
2
0
662
Feb ’25
Make Developer Forums Better!
Too many irrelevant posts come up when I attempt to search for something. There should be an easy button or something to earmark posts as something irrelevant- something that shouldn't come up in a search. I'm looking for something in Xcode 15 and frequently the top posts in the search are 10 years old and don't have any relevance whatsoever to the solution to my problem.
2
0
487
Feb ’25
Updated my Apple Watch to watchOS 26 beta to test it — can't pair it now after downgrading iPhone
Hi everyone, I updated my iPhone 16 Pro to iOS 26 beta and my Apple Watch to watchOS 26 beta because I wanted to test out the new features. After a few days of testing, I found the iOS 26 beta too unstable and laggy for daily use, so I downgraded my iPhone back to iOS 18.5 stable. Now my Apple Watch is still running watchOS 26 beta. I tried resetting it to factory settings, hoping that would help, but now I can’t pair it back to my iPhone because it requires iOS 26 again — which I don’t want to reinstall and don't want to use it till it's stable. Is there any way to downgrade my Apple Watch back to a stable version or somehow pair it again with my iPhone running iOS 18.5? Thanks in advance for any help!
2
0
137
Jun ’25
BLE Scan Response
The iPhone XS Max and Garmin watch pairing cannot use BLE to send Scan Response; it can only send BLE advertisements. May I ask if this is a limitation of the Apple system? So far, we have tested several iPhone models, and only the iPhone XS Max has this issue. We are not sure if other untested models have the same problem.
2
0
99
Jun ’25
Carplay grid in list
Hey everyone, I'm currently working on Carplay intergration in my audio app. While exploring Apple Music on carplay, i found this kind of display: This is a grid of items in a list (i'm on iOS 18 when testing this), but i didn't find anything in developer documentation that would allow me to have this kind of display. Is this something apple specific, or can i achieve this ? I tried using the grid template but it's not as pretty, nor as flexible as this. Thanks for your help !
2
0
111
Jun ’25
AirPod pro Firmware for iOS 26 not visible
I have updated my iPhone 14 Pro to iOS 26 without any problems. I also have AirPod Pro A2698 version 7E93. The new update of the firmware is not shown.developer mode is activated.on the pre-release is AirPod Pro visible if connected but no possibility for an update.what am I doing wrong or is there any thing I have to wait for thank you
2
1
339
Jun ’25
watchOS 26 cause Battery drain fast
After the last OS26 developer beta update the watch series 6 battery drains fast, in less than two hours life. I visited Apple Store , they said the battery was dead so I had to buy new watch series 10 The same issue happened in the new watch, the battery meter shows 50% after 1 hour Right now I’ve downgraded my update version to beta 11 until I can find a solution
2
2
594
Jun ’25
UI & App related
Due to it's new UI with transprent theme, sometimes its lacked between switching the apps. Please add AI eraser in photos app so that we can experience new ai tool. Due to india region, unable to use wallet options, Please add some options so that we can add cards and use this option.
2
0
94
Jun ’25
Swift Student Challenge Playgrounds app in 3 min
I intend to participate in the Swift Student Challenge 25. I see Rules, It is mentioned that Playgrounds works should be a work that can be experienced in three minutes. However, my work does not meet this requirement. Create an interactive scene in an app playground that can be experienced within three minutes. Initially, my work was not intended for the Challenge but for the App Store. However, I decided to submit it to the Challenge, and my work and I met the requirements of the Challenge. Therefore, my work is a complete application, which makes it impossible for the judges to experience it within three minutes. It may take more time. Does this have any impact?
2
0
671
Jan ’25
IOS 26.1 beta crashes prores raw external recording
Hi I experience this problem after update to the newest developer beta software on my iphone 17 pro: blackmagic camera said "storage full" although it is not final cut camera said "close and open the app again" It still works with prores (not raw). Anyone has the same problem as mine? I did try uninstall and reinstall the app and also restart the phone, try using different external ssd drive but nothing works.
2
1
533
Sep ’25
IOS 26`
Anyone else's phone die after installed iOS 26 beta? I'm not happy at all. shows that my phone is charging but will not turn on. have tried hard resetting it 50+ times, 5 different chargers.. nothing.
2
1
295
Jun ’25