Post

Replies

Boosts

Views

Activity

How do I update CloudKit whenever there is a change in Contacts in iOS?
Is there any way to run code in iOS whenever new information are added to certain contacts in contact store? If I use Notifications, I would have to have a process running at all times, since contacts are able to be changed by Apple's Contacts app. I have looked at App Extensions and there are no extensions I that can be used. There is a way to run a background process but I recall that has a limited lifespan. Am I correct about this? I need to update data in CloudKit that saves contacts information that can be shared with other users using their own Apple ID's. CloudKit subscriptions notify my app when something changes in CloudKit, but I also need to update records in CloudKit when something changes in Contacts. Anyone have any ideas how this might possibly be done?
2
0
1k
Jun ’22
How does my app know when iOS calls completionHandler of completeRequest(returningItems:completionHandler:)?
In this documentation for completeRequest(returningItems:completionHandler:), there is a box shaded yellow that says: Important If the system calls your block with an expired value of true, you must immediately suspend your app extension. If you fail to do this, the system terminates your extension’s process. How does my app or my Share Extension know when the system calls the block spoken of?
2
0
741
Jul ’22
When will type Error not cast to type NSError?
The sample project CloudKitShare downloaded from developer.apple.com Sharing CloudKit Data with Other iCloud Users has a line of code in HandleCloudKitError.swift that optionally casts an instance of Error to a variable of type NSError. guard let nsError = error as NSError? else { return nil } Under what conditions would this fail? I thought this would always succeed. How do I find out why the cast is unsuccessful? When I put code that prints the type of variable 'error', it seems to always result in Optional like so: Code: guard let nsError = error as NSError? else { print(type(of: error)) return nil } Optional
2
0
494
Aug ’22
What is the purpose of a line of code that says: '_ = viewController.view'?
What is the purpose of the following line of code? It doesn't seem to do anything. If it were in Playground or in a print statement it would at least show something. _ = masterVC.view It's in Apple's sample code at Sharing CloudKit Data with Other iCloud Users. Here's the complete significant code that contains that line of code: if let masterVC = masterNC?.viewControllers.first as? ZoneViewController {       _ = masterVC.view       start ? masterVC.spinner.startAnimating() : masterVC.spinner.stopAnimating() }
2
0
314
Aug ’22
How do I make a pop-up menu in iOS?
What framework would I use to make one of those popup menus that I see when I long press a field when I look at a Contact in Contacts. The popup menu is black. It looks like a horizontal bar with items separated by a very think vertical white line between each item. When I press a field while viewing a Contact, the menu gives an option to Copy and another option for iPhone to Speak.
2
0
1.5k
Dec ’22
How do I set UICloudSharingController.availablePermissions to not allow participants other than the owner of CKShare to copy or send a link from UICloudSharingController?
I have an app that uses CKShare and UICloudSharingController to share data with other users of my app. I noticed that when Owner shares with UserA, UserA is able to "copy" the link or "send" the link, as the title of the button use. How do I disable that completely so that only the owner can copy or send the link? Also, what determines whether it says "Copy Link" or "Send Link"? Does that have to do with the version of iOS? I've tried every combination of UICloudSharingController.PermissionOptions to set to UICloudSharingController..availablePermissions ... [.allowPrivate, .allowReadOnly], [.allowReadOnly], [.allowPrivate], and []. Setting the value to [] sets it to .standard, which does the exact same thing as [.allowPrivate, .allowReadOnly], though the value is different for availablePermissions property.
2
0
855
Dec ’22
"PosterBoard quit unexpectedly." warning in my Mac running macOS 13.4.1(c)
I don't see any current posts about the warning that says "PosterBoard quit unexpectedly." on my Mac. Older posts say this is an error generated by Xcode Simulator. I tried one of those solutions but I still see this warning coming up. I am also not using Simulator. I'm using an actual device - an iPhone 13 Pro Max running iOS 16.6. When I click on Reopen in that alert box telling me that warning message, I get a warning in an alert box with a picture of the Finder icon on it, and it says "You can’t open the application “PosterBoard.app” because this application is not supported on this Mac.". Anyone else have this problem and know what do do about it? Like fix it or get around it?
2
0
1k
Aug ’23
save audio file in iOS 18 instead of iOS 12
I'm able to get text to speech to audio file using the following code for iOS 12 iPhone 8 to create a car file: audioFile = try AVAudioFile( forWriting: saveToURL, settings: pcmBuffer.format.settings, commonFormat: .pcmFormatInt16, interleaved: false) where pcmBuffer.format.settings is: [AVAudioFileTypeKey: kAudioFileMP3Type, AVSampleRateKey: 48000, AVEncoderBitRateKey: 128000, AVNumberOfChannelsKey: 2, AVFormatIDKey: kAudioFormatLinearPCM] However, this code does not work when I run the app in iOS 18 on iPhone 13 Pro Max. The audio file is created, but it doesn't sound right. It has a lot of static and it seems the speech is very low pitch. Can anyone give me a hint or an answer?
2
0
105
Mar ’25
Why are table view cells not showing in table view?
I am using more than one table view cell class on a table view. I have registered the reuse identifiers and the xibs. For some reason the cells are not showing. What should I check. I'm stumped.Here is my code:import UIKit class DetailTableViewController: UITableViewController { let items = [0, 1] override func viewDidLoad() { super.viewDidLoad() tableView.register(DueDateSwitchTableViewCell.self, forCellReuseIdentifier: "DueDateSwitchTableViewCell") let xibDueDateSwitchTableViewCell = UINib(nibName: "DueDateSwitchTableViewCell", bundle: Bundle.main) tableView.register(xibDueDateSwitchTableViewCell, forCellReuseIdentifier: "DueDateSwitchTableViewCell") tableView.register(DueDatePickerTableViewCell.self, forCellReuseIdentifier: "DueDatePickerTableViewCell") let xibDueDatePickerTableViewCell = UINib(nibName: "DueDatePickerTableViewCell", bundle: Bundle.main) tableView.register(xibDueDatePickerTableViewCell, forCellReuseIdentifier: "DueDatePickerTableViewCell") } override func numberOfSections(in tableView: UITableView) -> Int { return 1 } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return items.count } override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { print("tableView(_:cellForRowAt:)", "indexPath.row=", indexPath.row) let cell = UITableViewCell() switch indexPath.row { case 0: print("\tcase 0") let cell = tableView.dequeueReusableCell(withIdentifier: "DueDateSwitchTableViewCell", for: indexPath) as! DueDateSwitchTableViewCell cell.backgroundColor = UIColor.yellow case 1: print("\tcase 1") let cell = tableView.dequeueReusableCell(withIdentifier: "DueDatePickerTableViewCell", for: indexPath) as! DueDatePickerTableViewCell cell.datePicker.date = Date() default: break } return cell } }The cells show the numbers when I use this code in tableView(_:cellForRowAt:) before the line that says "return cell": cell.textLabel!.text = String(items[indexPath.section].hashValue)
Topic: UI Frameworks SubTopic: UIKit Tags:
3
0
13k
Jul ’21
Why does ShapeEdit use FileManager copyItem instead of setUbiquitous?
I have a question about code in the ShapeEdit sample from Apple.I their code, as shown below, why did they use FileManager's copyItem method instead of its setUbiquitous method? Didn't the documentation say explicitly to use setUbiquitous method? NSFileCoordinator().coordinate(with: [readIntent, writeIntent], queue: self.coordinationQueue) { error in if error != nil { return } do { try fileManager.copyItem(at: readIntent.url, to: writeIntent.url) try (writeIntent.url as NSURL).setResourceValue(true, forKey: URLResourceKey.hasHiddenExtensionKey) OperationQueue.main.addOperation { self.openDocumentAtURL(writeIntent.url) } } catch { fatalError("Unexpected error during trivial file operations: \(error)") } }
1
0
938
Jan ’21