Post

Replies

Boosts

Views

Activity

How do I convert an struct of type Data to an object of type CNGroup?
I'm having trouble converting a CNGroup object to a Data object and back to a CNGroup object. I decided to start rethinking the problem again. Somewhere along the way I decided that I should use the Data class to save a CNGroup object to CloudKit. I also learned that the field type to use in my CKRecord object would be of the type bytes. Am I correct so far? I am able to convert a CNGroup object to a Data object and back again unless I store the Data object in CloudKit and then retrieve it before I convert the Data object back to a CNGroup object, in which case I get an error when I try to access the pointee property of the typed pointer. That would be an UnsafeBufferPointer, an UnsafeMutableBufferPointer, or an UnsafePointer. I've tried a lot of different code using different ways. It is impractical to put so much code in my post. I have used the copyBytes method and the withUnsafeBytes method of the Data object. There is one simple code, and that is when I converted the CNGroup object to a Data object: func convertCNGroupToData(fromCNGroup group: inout CNGroup) -> Data { return Data(bytes: &group, count: MemoryLayout.size(ofValue: group)) } I am looking for a simple way to do what I want. I am relooking at Apple's documentation of Data and NSData. I am not able to be more specific with this question. I appreciate any effort to help me with this.
1
0
608
Apr ’22
Xcode dialog box with message "Unable to lookup in current state: Shutdown"
I've never had this error before. When I try to run an iOS project in Xcode with a simulator, I get this message from XCode: "Unable to lookup in current state: Shutdown", and a button that says "Details", and a button that says"OK". When I quit simulator and try to run my project again, the same thing happens. When I click details it says "iPhone10,4 for device_model. The simulator is an iPhone 8 simulator. Here is what the whole thing says: (I don't know why some of the text has such a large font and is in bold.) Details Unable to lookup in current state: Shutdown Domain: com.apple.CoreSimulator.SimError Code: 405 User Info: {     DVTErrorCreationDateKey = "2022-04-16 23:02:18 +0000";     IDERunOperationFailingWorker = IDELaunchiPhoneSimulatorLauncher; } Analytics Event: com.apple.dt.IDERunOperationWorkerFinished : {     "device_model" = "iPhone10,4";     "device_osBuild" = "15.4 (19E240)";     "device_platform" = "com.apple.platform.iphonesimulator";     "launchSession_schemeCommand" = Run;     "launchSession_state" = 1;     "launchSession_targetArch" = "x86_64";     "operation_duration_ms" = 22;     "operation_errorCode" = 405;     "operation_errorDomain" = "com.apple.CoreSimulator.SimError";     "operation_errorWorker" = IDELaunchiPhoneSimulatorLauncher;     "operation_name" = IDERunOperationWorkerGroup;     "param_consoleMode" = 0;     "param_debugger_attachToExtensions" = 0;     "param_debugger_attachToXPC" = 1;     "param_debugger_type" = 3;     "param_destination_isProxy" = 0;     "param_destination_platform" = "com.apple.platform.iphonesimulator";  "param_diag_MainThreadChecker_stopOnIssue" = 0;  "param_diag_MallocStackLogging_enableDuringAttach" = 0; "param_diag_MallocStackLogging_enableForXPC" = 1;     "param_diag_allowLocationSimulation" = 1;     "param_diag_gpu_frameCapture_enable" = 0;    "param_diag_gpu_shaderValidation_enable" = 0;     "param_diag_gpu_validation_enable" = 0; "param_diag_memoryGraphOnResourceException" = 0;     "param_diag_queueDebugging_enable" = 1;     "param_diag_runtimeProfile_generate" = 0;     "param_diag_sanitizer_asan_enable" = 0;     "param_diag_sanitizer_tsan_enable" = 0;     "param_diag_sanitizer_tsan_stopOnIssue" = 0;   "param_diag_sanitizer_ubsan_stopOnIssue" = 0;     "param_diag_showNonLocalizedStrings" = 0;     "param_diag_viewDebugging_enabled" = 1;  "param_diag_viewDebugging_insertDylibOnLaunch" = 1;     "param_install_style" = 0;     "param_launcher_UID" = 2;  "param_launcher_allowDeviceSensorReplayData" = 0;     "param_launcher_kind" = 0;     "param_launcher_style" = 0;     "param_launcher_substyle" = 0;  "param_runnable_appExtensionHostRunMode" = 0;     "param_runnable_productType" = "com.apple.product-type.application";     "param_runnable_swiftVersion" = "5.6";     "param_runnable_type" = 2;     "param_testing_launchedForTesting" = 0;     "param_testing_suppressSimulatorApp" = 0;     "param_testing_usingCLI" = 0;     "sdk_canonicalName" = "iphonesimulator15.4";     "sdk_osVersion" = "15.4";     "sdk_variant" = iphonesimulator; } -- System Information macOS Version 12.3.1 (Build 21E258) Xcode 13.3.1 (20103) (Build 13E500a) Timestamp: 2022-04-16T18:02:18-05:00
0
0
927
Apr ’22
Account temporarily unavailable due to bad or missing auth token
I got this message "Account temporarily unavailable due to bad or missing auth token" when I try to save to privateDatabase in CloudKit, using the CKDatabase.save(record:completionHandler). It looks like the error that was posted about here on stackoverflow has reappeared. The fix for that other problem was a bug in Apple's side. Anyone have this problem recently and have a solution?
0
0
1.2k
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
400
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
327
Apr ’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
573
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
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
779
May ’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
1.1k
Jun ’22
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
722
Jun ’22
what can you use after the escape character "\"?
Where can I find a list of those characters that can be put in front of the ""character in a string literal, such as "n", thus the following would print a new line? I don't know what those characters are called. I thought they were called "escape characters" or "format specifiers". print("\n", terminator: "")
1
0
394
Jun ’22
How do I convert an struct of type Data to an object of type CNGroup?
I'm having trouble converting a CNGroup object to a Data object and back to a CNGroup object. I decided to start rethinking the problem again. Somewhere along the way I decided that I should use the Data class to save a CNGroup object to CloudKit. I also learned that the field type to use in my CKRecord object would be of the type bytes. Am I correct so far? I am able to convert a CNGroup object to a Data object and back again unless I store the Data object in CloudKit and then retrieve it before I convert the Data object back to a CNGroup object, in which case I get an error when I try to access the pointee property of the typed pointer. That would be an UnsafeBufferPointer, an UnsafeMutableBufferPointer, or an UnsafePointer. I've tried a lot of different code using different ways. It is impractical to put so much code in my post. I have used the copyBytes method and the withUnsafeBytes method of the Data object. There is one simple code, and that is when I converted the CNGroup object to a Data object: func convertCNGroupToData(fromCNGroup group: inout CNGroup) -> Data { return Data(bytes: &group, count: MemoryLayout.size(ofValue: group)) } I am looking for a simple way to do what I want. I am relooking at Apple's documentation of Data and NSData. I am not able to be more specific with this question. I appreciate any effort to help me with this.
Replies
1
Boosts
0
Views
608
Activity
Apr ’22
Xcode dialog box with message "Unable to lookup in current state: Shutdown"
I've never had this error before. When I try to run an iOS project in Xcode with a simulator, I get this message from XCode: "Unable to lookup in current state: Shutdown", and a button that says "Details", and a button that says"OK". When I quit simulator and try to run my project again, the same thing happens. When I click details it says "iPhone10,4 for device_model. The simulator is an iPhone 8 simulator. Here is what the whole thing says: (I don't know why some of the text has such a large font and is in bold.) Details Unable to lookup in current state: Shutdown Domain: com.apple.CoreSimulator.SimError Code: 405 User Info: {     DVTErrorCreationDateKey = "2022-04-16 23:02:18 +0000";     IDERunOperationFailingWorker = IDELaunchiPhoneSimulatorLauncher; } Analytics Event: com.apple.dt.IDERunOperationWorkerFinished : {     "device_model" = "iPhone10,4";     "device_osBuild" = "15.4 (19E240)";     "device_platform" = "com.apple.platform.iphonesimulator";     "launchSession_schemeCommand" = Run;     "launchSession_state" = 1;     "launchSession_targetArch" = "x86_64";     "operation_duration_ms" = 22;     "operation_errorCode" = 405;     "operation_errorDomain" = "com.apple.CoreSimulator.SimError";     "operation_errorWorker" = IDELaunchiPhoneSimulatorLauncher;     "operation_name" = IDERunOperationWorkerGroup;     "param_consoleMode" = 0;     "param_debugger_attachToExtensions" = 0;     "param_debugger_attachToXPC" = 1;     "param_debugger_type" = 3;     "param_destination_isProxy" = 0;     "param_destination_platform" = "com.apple.platform.iphonesimulator";  "param_diag_MainThreadChecker_stopOnIssue" = 0;  "param_diag_MallocStackLogging_enableDuringAttach" = 0; "param_diag_MallocStackLogging_enableForXPC" = 1;     "param_diag_allowLocationSimulation" = 1;     "param_diag_gpu_frameCapture_enable" = 0;    "param_diag_gpu_shaderValidation_enable" = 0;     "param_diag_gpu_validation_enable" = 0; "param_diag_memoryGraphOnResourceException" = 0;     "param_diag_queueDebugging_enable" = 1;     "param_diag_runtimeProfile_generate" = 0;     "param_diag_sanitizer_asan_enable" = 0;     "param_diag_sanitizer_tsan_enable" = 0;     "param_diag_sanitizer_tsan_stopOnIssue" = 0;   "param_diag_sanitizer_ubsan_stopOnIssue" = 0;     "param_diag_showNonLocalizedStrings" = 0;     "param_diag_viewDebugging_enabled" = 1;  "param_diag_viewDebugging_insertDylibOnLaunch" = 1;     "param_install_style" = 0;     "param_launcher_UID" = 2;  "param_launcher_allowDeviceSensorReplayData" = 0;     "param_launcher_kind" = 0;     "param_launcher_style" = 0;     "param_launcher_substyle" = 0;  "param_runnable_appExtensionHostRunMode" = 0;     "param_runnable_productType" = "com.apple.product-type.application";     "param_runnable_swiftVersion" = "5.6";     "param_runnable_type" = 2;     "param_testing_launchedForTesting" = 0;     "param_testing_suppressSimulatorApp" = 0;     "param_testing_usingCLI" = 0;     "sdk_canonicalName" = "iphonesimulator15.4";     "sdk_osVersion" = "15.4";     "sdk_variant" = iphonesimulator; } -- System Information macOS Version 12.3.1 (Build 21E258) Xcode 13.3.1 (20103) (Build 13E500a) Timestamp: 2022-04-16T18:02:18-05:00
Replies
0
Boosts
0
Views
927
Activity
Apr ’22
Account temporarily unavailable due to bad or missing auth token
I got this message "Account temporarily unavailable due to bad or missing auth token" when I try to save to privateDatabase in CloudKit, using the CKDatabase.save(record:completionHandler). It looks like the error that was posted about here on stackoverflow has reappeared. The fix for that other problem was a bug in Apple's side. Anyone have this problem recently and have a solution?
Replies
0
Boosts
0
Views
1.2k
Activity
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?
Replies
1
Boosts
0
Views
400
Activity
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?
Replies
0
Boosts
0
Views
327
Activity
Apr ’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".
Replies
1
Boosts
0
Views
573
Activity
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.
Replies
1
Boosts
0
Views
1.5k
Activity
Apr ’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?
Replies
1
Boosts
0
Views
779
Activity
May ’22
When I add or remove records to a share's hierarchy using CKModifyRecordsOperation, do I need to include the share in the recordsToSave argument?
When I add or remove records to a share's hierarchy using CKModifyRecordsOperation, do I need to include the share in the recordsToSave argument of one of the convenience initializers or the property recordsToSave property?
Replies
1
Boosts
0
Views
446
Activity
Jun ’22
What does CNContactStoreDidChange notification notify multiple times for a single change my app makes itself?
What does CNContactStoreDidChange notification notify multiple times for a single change my app makes itself?
Replies
0
Boosts
0
Views
611
Activity
Jun ’22
What word means to make something true if it is at first false?
What is the word in programming that means that checks a condition for true or false, and if the condition is false, code is run to make that condition true, so that if the condition is checked again, it would be true? I believe I have seen something in Swift or Foundations that does this as applied to different things.
Replies
5
Boosts
0
Views
690
Activity
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?
Replies
2
Boosts
0
Views
1.1k
Activity
Jun ’22
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(...) {...}
Replies
1
Boosts
0
Views
722
Activity
Jun ’22
what can you use after the escape character "\"?
Where can I find a list of those characters that can be put in front of the ""character in a string literal, such as "n", thus the following would print a new line? I don't know what those characters are called. I thought they were called "escape characters" or "format specifiers". print("\n", terminator: "")
Replies
1
Boosts
0
Views
394
Activity
Jun ’22
What would happen if I add an index to a record type into production that wasn't there before in CloudKit?
What would happen if I add an index to a record type in development that isn't there in production, then I deploy the development into production?
Replies
2
Boosts
0
Views
879
Activity
Jun ’22