Does CKRecordZoneID need to be unique per user? - ios

Is a CloudKit record zone created per user basis, or does it apply to everyone?
A CKRecordZoneID object uniquely identifies a record zone in a database.
This seems to imply that it's affecting for everyone.
A record zone ID distinguishes one zone from another by a name string and the ID of the user that created the zone.
However, the fact that the ID appends the owner name, made it sound like it's per user basis?
The reason why I'm asking is I'd like to know if I can create a single RecordZoneID for the app or does it need to be stored per user (in NSUserDefaults)

The short answer is that zone names only need to be unique among the other zones in a user's private database.
There's a subtle but important difference between a CKRecordZoneID and a zone name.
A CKRecordZoneID must be unique across your entire container, but a CKRecordZoneID is more than just the zone name.
If you look at CKRecordZoneID you'll see that it has both a zoneName property and an ownerName property. The ownerName is the record ID of the current user (or CKOwnerDefaultName, which gets replaced by the real user ID before the value is sent to the server).
The combination of zoneName and ownerName must be unique across the container, but since every user has their own unique user ID (which is used for ownerName) you can create a zone with the same zoneName for every user and not have any conflicts.

Related

How to count cases with the same ID but different variables in SPSS

I have a data set which has 4420 attendances to a medical department from 1120 people. Each person has a unique ID number and other columns are demographics and primary care provider. I want to filter the data so I can work out how many times each person attends the department and then analyse the data by demographics eg primary care provider or age. It shows whether each attendance is primary or duplicate but I can't figure out how to work out attendances per person.
If what you want to do is to count the number of times each person has visited (assuming each one is represented by a single row in the data), use the AGGREGATE command breaking on the ID variable to add the number of instances to the file as a new variable. In the menus, Data>Aggregate, move the ID variable into the box for Break Variable(s), check the box for Number of cases under Aggregated Variables, change the default N_BREAK to another name if you want, and click OK. That will add a new variable to the data with the number of instances for each unique ID.

Is it legit to change the CKRecordID of a CKRecord in Cloudkit?

I have an object Person and an object Address. I want to store these objects to Cloudkit. It is possible that multiple persons have the same address, so there is a 1:m relationship. I store a ckreference on the person object. Now I wonder, if I should give the address a random recordid/recordname provided from cloudkit ore one consisting of the addressdetails, eg. street, city ...
The later solution would mean, I must change the address recordid everytime I'll change details.
Does that have any sideeffects on the person's address ckreference? Which solution is better more usable?
In CloudKit references are declared using the CKReference class. Don't reinvent the wheel ;-)
A CKRecord identifier never changes.
You have to take care about the kind of referenceAction selected at CKReference creation time. Setting .deleteSelf only allow a limited records references to that record, in the other hand, a .none reference action allows you an unlimimted number of references to that CKRecord.
The best choice is CKReference.

Graph API calendarid is not unique and changing

I have noticed that the calendar id is not a unique value and it changes for reasons unknown.
I have stored some calendar id values in a database. At a later point when tried to insert events using those values, the id stored in database no longer matches the Calendar id in Microsoft Graph. Upon investigation the calendar id has been changed in the last few characters.
Can someone explain this anomaly please? any workarounds
Regards
For an event, the id property is a composite value based on a number of other properties. If something changes (such as the path to the item), the id value will change. So while it is unique to a mailbox, it is not suitable for a permanent reference to the event.
With an event, you should use the iCalUid property. This is a unique value that is permanently persisted across all calendars. So even if the event is a meeting with multiple attendees, each attendee will persist the same iCalUid even if an attendee isn't part of your organization, or even on Exchange).
For the Calendar itself, I wouldn't expect the id to change unexpectedly (i.e. the user didn't delete and recreate or edit the calendar itself in some way).

Storing integer that all mobile users can access

I want to make a database for an iOS application consisting of groups that can have the same name. I am hosting my database on AWSDynamo.
Since multiple groups can have the same name, I was planning on having a groupID as the hashkey, unless someone can suggest a better method.
My main problem is storing an integer that will be the number of groups. This is so that when a user creates a new group the number will be incremented and the new group will get that number as its groupID.
How can I store an integer in such a fashion that all users can access it from the app?
UUID – Universally unique identifier
You can use a UUID (String) as your groupID in your groups table, and use conditional writes (PutItem, UpdateItem) to handle the extremely rare case where there is a collision. If you create a UUID for a new group where the UUID already is assigned to another group, you will get a ConditionalCheckFailedException so you can retry with a new UUID. You don't need to use an incrementing sequence to uniquely identify groups.

discoverAllContactUserInfosWithCompletionHandler returning multiple records for same user?

When I invoke discoverAllContactUserInfosWithCompletionHandler: the returned array of CKDiscoveredUserInfo has three distinct userRecordIDs but these are all for a person with the same firstName + lastName. The three userRecordIDs share the same recordName but differ by zoneID. As best I can figure this is the same person with three 'iCloud' email addresses: icloud.com, me.com, mac.com. Presenting all three in my App's UI is a non-starter given that they are indistinguishable.
Is there any reason to choose one of the multiple records over another? Is my presumption that they are indeed different iCloud mail addresses correct? Can I go from userRecordID to email?
[I know the email accounts; presumably I could query with discoverUserInfoWithEmailAddress:completionHandler and correlate the results myself.
The recordName is the only part that really matters here, but it's odd that the userRecordIDs have different zoneIDs. They should all be in the default public zone, so you might be hitting a bug. What zone IDs are you seeing?
If you have to pick one record ID, go with the one in -[CKRecordZone defaultRecordZone]

Resources