Post

Replies

Boosts

Views

Activity

Reducing overhead of CKRecord.encodeSystemFields
TL;DR: I'm syncing a local database to CloudKit and I'd like to store only the CKRecord's recordChangeTag locally, because the archived system fields are quite large. Is there any way to create a CKRecord with a given recordChangeTag? I'm working on syncing an on-device database to CloudKit. As part of this I need to remember the CloudKit state of every database record, so I when that record changes I can create a CKRecord for it and push it to the server. The supported way to do this is to call CKRecord.encodeSystemFields on the resulting record after the push, and save that archived data alongside the local record so it can be reconstituted into a CKRecord next time I need to push that database row. The problem is that this archived data is pretty heavyweight, generally about 1600 bytes. That's not a lot for one record, but for 60,000 records it's 100MB of extra data to store (and read and write.) As far as I can tell, the only really crucial part of a CKRecord to push (besides the ID and type, which I already know) is the recordChangeTag — this is what the server uses as the MVCC token to reject conflicting updates. And this tag is tiny: it appears to be a hex-encoded generation count, so it's usually 1 or 2 bytes. I'd like to store just this tag. But I can't use it to reconstitute a CKRecord, because that property isn't settable. Is there any workaround?
1
0
829
Jun ’23
WKNavigationDelegate never called (Obj-C, macOS)
I'm adding a WKWebView to my (Mac) app, and it works fine except that the navigationDelegate is never called. Even stranger, if that delegate implements decidePolicyForNavigationAction, that method is never called either, but as a side effect the view now won't load any pages! In detail: I've created a class implementing WKNavigationDelegate, I've implemented some of the methods, and assigned an instance to the view's navigationDelegate property. Easy stuff. I've done this in the past using the old-school WebView class. I've triple-checked my work. As an experiment, I added a -respondsToSelector: method to my delegate class and made it log the selector. I see it being called several dozen times, with the selectors for all of the delegate methods and many other private(?) methods; so I know WebKit sees my object. It just never calls it at all. My hunch so far is that this is an OS bug, that Apple no longer bothers to test WebKit APIs in Objective-C. I'd hate for that to be true. (I realize Obj-C is basically deprecated nowadays. I'm using it because my non-UI code is all in C++, and it's vastly easier to integrate with C++ in Obj-C. To use Swift I'm going to have to wrap my API in C functions, yuck.)
4
0
2.4k
May ’22
Reducing overhead of CKRecord.encodeSystemFields
TL;DR: I'm syncing a local database to CloudKit and I'd like to store only the CKRecord's recordChangeTag locally, because the archived system fields are quite large. Is there any way to create a CKRecord with a given recordChangeTag? I'm working on syncing an on-device database to CloudKit. As part of this I need to remember the CloudKit state of every database record, so I when that record changes I can create a CKRecord for it and push it to the server. The supported way to do this is to call CKRecord.encodeSystemFields on the resulting record after the push, and save that archived data alongside the local record so it can be reconstituted into a CKRecord next time I need to push that database row. The problem is that this archived data is pretty heavyweight, generally about 1600 bytes. That's not a lot for one record, but for 60,000 records it's 100MB of extra data to store (and read and write.) As far as I can tell, the only really crucial part of a CKRecord to push (besides the ID and type, which I already know) is the recordChangeTag — this is what the server uses as the MVCC token to reject conflicting updates. And this tag is tiny: it appears to be a hex-encoded generation count, so it's usually 1 or 2 bytes. I'd like to store just this tag. But I can't use it to reconstitute a CKRecord, because that property isn't settable. Is there any workaround?
Replies
1
Boosts
0
Views
829
Activity
Jun ’23
WKNavigationDelegate never called (Obj-C, macOS)
I'm adding a WKWebView to my (Mac) app, and it works fine except that the navigationDelegate is never called. Even stranger, if that delegate implements decidePolicyForNavigationAction, that method is never called either, but as a side effect the view now won't load any pages! In detail: I've created a class implementing WKNavigationDelegate, I've implemented some of the methods, and assigned an instance to the view's navigationDelegate property. Easy stuff. I've done this in the past using the old-school WebView class. I've triple-checked my work. As an experiment, I added a -respondsToSelector: method to my delegate class and made it log the selector. I see it being called several dozen times, with the selectors for all of the delegate methods and many other private(?) methods; so I know WebKit sees my object. It just never calls it at all. My hunch so far is that this is an OS bug, that Apple no longer bothers to test WebKit APIs in Objective-C. I'd hate for that to be true. (I realize Obj-C is basically deprecated nowadays. I'm using it because my non-UI code is all in C++, and it's vastly easier to integrate with C++ in Obj-C. To use Swift I'm going to have to wrap my API in C functions, yuck.)
Replies
4
Boosts
0
Views
2.4k
Activity
May ’22