Post

Replies

Boosts

Views

Activity

Backward compatibility of NSKeyedUnarchiver class of Apple Foundations for iOS
I'm getting errors when I use NSKeyedArchiver and NSKeyedUnarchiver that works with iOS 15.5 but not with iOS 12.4 nor iOS 12.5.5. I have tried combinations of using devices and simulators. The error message appears in the Xcode debug window when the catch scope handles an error that occurs when the following statement executes: try NSKeyedUnarchiver.unarchivedObject(ofClass: CNGroup.self, from: dataToUnarchive) Here is what prints in the Xcode debug window for Error.localizedDescription: The data couldn’t be read because it isn’t in the correct format. Here is what prints in the Xcode debug window when only the Error object is put in the print statement parentheses: Error Domain=NSCocoaErrorDomain Code=4864 "*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: incomprehensible archive (0x62, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4)" UserInfo={NSDebugDescription=*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: incomprehensible archive (0x62, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4)} I found an answer to a similar question like this in Apple Developer Forums which had to do with NSCoder that indicated that the older iOS expects the Data object not to use secure coding, my code as this post concerns is not using secure coding. There are stackoverflow questions that deal with similar questions to mine, but they are very old and they deal with different facets of NSCoder. The following are the respective function definitions for archive(cnGroup:completionHandler:) and unarchive(dataOfCNGroup:completionHandler) that I use. Definition for unarchive(dataOfCNGroup:completionHandler) func archive(cnGroup: CNGroup, completionHandler: @escaping (Result<Data, Error>)->Void) { do { if #available(iOS 11.0, *) { let data: Data = try NSKeyedArchiver.archivedData(withRootObject: cnGroup, requiringSecureCoding: false) completionHandler(.success(data)) } else { let data: Data = NSKeyedArchiver.archivedData(withRootObject: cnGroup) completionHandler(.success(data)) } } catch { completionHandler(.failure(error)) } } // func archive(...) {...} Definition for archive(cnGroup:completionHandler:) func unarchive(dataOfCNGroup dataToUnarchive: Data, completionHandler: @escaping (Result<CNGroup, Error>)->Void) { print("func unarchive(dataOfCNGroup dataToUnarchive: Data, completionHandler: @escaping (Result<CNGroup, Error>)->Void)") do { if let unwrappedUnarchivedCNGroup: CNGroup = try NSKeyedUnarchiver.unarchivedObject(ofClass: CNGroup.self, from: dataToUnarchive) { completionHandler(.success(unwrappedUnarchivedCNGroup)) } else { let nsError = NSError(domain: "func unarchive(dataOfCNGroup dataToUnarchive: Data, completionHandler: @escaping (Result<CNGroup, Error>?)->Void)", code: #line, userInfo: nil) let error: Error = nsError completionHandler(.failure(error)) return } } catch { print("catch error in unarchive(dataOfCNGroup:_:) on line \(#line)") print("\(error.localizedDescription)") completionHandler(.failure(error)) } } // func unarchive(...) {...}
1
0
709
Jun ’22
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
Why does UICloudSharingController ask to add participants when I choose to let anyone with the link have access?
I'm trying out UICloudSharingController. I noticed that When I select "Anyone with the link" for "WHO CAN ACCESS" in Share Options, then click to copy the link, a screen comes up saying "Add People" at the top. If anyone with a link can access this share, why does it ask me to add participants? It seems I remember that before it didn't ask me to add participants when I select "Anyone with the link".
1
0
563
May ’22
How to know what number is a user calls?
I’m looking for ideas here. Is there anyway I can access the record of which calls a user has made. I would like to figure out a way to know which numbers a user uses most. I want to be able to set a default number for each contact in my app that the user uses. Is there so way I can determine what default phone number user would normally call for a contact?
1
0
772
May ’22
"Provisioning profile "iOS Team Provisioning Profile: ***" doesn't include the com.apple.developer.contacts.notes entitlement.
"Provisioning profile "iOS Team Provisioning Profile: ***" doesn't include the com.apple.developer.contacts.notes entitlement. I'm looking for a cause to this problem. It happened when I tried to run a project on an old iPhone 5. I didn't get this problem with any of the other devices and simulators.
1
0
1.5k
Apr ’22
Blank project page in Xcode
When I click on my Project in Xcode I get a balnk page. I mean the very top level item of the tree in the Project navigator on the left page. The one that has the name of my project. It does this sometimes. I haven't found any recent posts about this. Anyone else have this problem? Anyone know the solution?
1
0
1.8k
Apr ’22
Does UICloudSharingController.availablePermissions adjust itself to the CKShare.publicPermission and CKShare.currentUserParticipant.participantRole?
Does UICloudSharingController.availablePermissions adjust itself to the CKShare.publicPermission and CKShare.currentUserParticipant.participantRole of an existing CKShare object I initialize UICloudSharingController with, or do I have to manually set availablePermissions according to what those CKShare properties are set to?
0
0
322
Apr ’22
What is the difference between CKShare.ParticipantRole.privateUser and CKShare.ParticipantRole.publicUser
What is the difference between CKShare.ParticipantRole.privateUser and CKShare.ParticipantRole.publicUser? Does this together with CKShare.ParticipantPermission determine whether the participant is able to share the share with others or not, or does ParticipantPermission determine both whether a participant can change the records that are shared as well as whom the participant can share the share with?
1
0
388
Apr ’22
Is it safe to update to macOS 12.3.1 without disrupting Xcode 13.3?
Before I update my macOS to 12.3.1, form 12.3, I want to know if anyone has installed it and if it interfered with Xcode. I heard that macOS updates faster than Xcode so that at times the new macOS requires a new Xcode that hasn't been released yet. I checked Mac App Store, and there isn't a version released after Xcode 13.3 (13E113).
2
0
1k
Apr ’22