YapDatabase icon indicating copy to clipboard operation
YapDatabase copied to clipboard

YapDatabaseCloudKitTransaction and YapDatabaseModifiedNotification

Open dezinezync opened this issue 9 years ago • 1 comments

I'm currently implementing the CloudKit extension in one of our apps. I recently got around to implementing the CKSubscription and have been receiving notifications successfully.

I do have one doubt though, which I'll try to illustrate below. (I have followed CKManager's architecture closely and have something similar in our app)

When the following is executed for a record modified on a different device,

[[transaction ext:CKExtension] getRecordChangeTag:&recordChangeTag
                                               hasPendingModifications:&hasPendingModifications
                                                      hasPendingDelete:&hasPendingDelete
                                                           forRecordID:record.recordID
                                                    databaseIdentifier:nil]

We get back a changeTag which differs with the current device's changeTag. Therefore, the extension must merge it.

[[transaction ext:CKExtension] mergeRecord:record databaseIdentifier:nil];

This happens successfully, and is visible when the data is periodically refreshed by the app, by the user or on next app launch. However, I was expecting the following method to fire a YapDatabaseModifiedNotification so I could update the views, if any, immediately:

- (void)mergeRecord:(CKRecord *)remoteRecord databaseIdentifier:(NSString *)databaseIdentifier

Was I wrong to expect so? Or perhaps I missed a step. Could someone please guide me in the right direction.

iOS: 9.3.2 iPhone 6S YapDatabase (latest from master)

dezinezync avatar Jun 12 '16 06:06 dezinezync

Not sure why @robbiehanson hasn't commented on this, but I'm currently having the same problem. In YapDatabaseConnection.h it clearly says:

A YapDatabaseModifiedNotification is posted for every readwrite transaction that makes changes to the database.

So with a trivial merge block like this:

Result *newResult = [[Result alloc] initWithRecord:remoteRecord]; [transaction setObject:newResult forKey:key inCollection:collection];

the rwConnection should fire a notification, but it doesn't.

uthiel avatar Nov 01 '16 20:11 uthiel