0

I've been looking at the documentation and can't seem to find a recommended Predicate which will provide only changed records from icloud.

I'm currently using TRUEPREDICATE which get all records.

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"TRUEPREDICATE"];

I can't find anything onFALSEPREDICATE.

I'm hoping there's already functionality to do this. I'm not using notifications, as I've found that they are unreliable. iOS, CloudKit - do I need to do a fetch when my app starts?

Also my app only needs to know changes at the start, I don't need to handle notifications in the background.

Deletes aren't a problem, as I'm keeping records with a removed flag to ensure they don't re-appear from an older device.

Doing a full fetch for all records when my app runs isn't ideal.

The only thing I can think of is storing the time and using a predicate against the record modified timestamp?

Jules
  • 7,568
  • 14
  • 102
  • 186
  • 1
    You should use a `CKFetchRecordChangesOperation` along with a locally stored token to retrieve changes since your last sync. I note that this is showing as deprecated in iOS 11, but there is no documentation on the recommended replacement. Even though it is deprecated it will work for he foreseeable future. – Paulw11 Aug 08 '17 at 21:02
  • @Paulw11should I not be using `CKFetchDatabaseChangesOperation` instead https://stackoverflow.com/questions/29140726/ckfetchrecordchangesoperation-returns-no-records ? Although there's mention of that not working on default zones. I have no clue what to do for the best. Thanks for your help. – Jules Aug 09 '17 at 08:14
  • That tells you about changes to the database itself; i.e. the addition and removal of zones. It doesn't tell you about changes to records. – Paulw11 Aug 09 '17 at 08:17
  • @Paulw11 thanks. Trying to find some objective c examples, struggling. – Jules Aug 09 '17 at 08:18
  • I can't help with Objective-C code. You can see Swift code here; https://github.com/paulw11/Seam3/blob/master/Sources/Classes/SMStoreSyncOperation.swift The Objective-C will be the same; you just need to specify the appropriate blocks instead of the Swift closures – Paulw11 Aug 09 '17 at 08:21
  • @Paulw11 will I have to swap to a custom zone with my private container? I'm not sure whether that will cause me other issues. – Jules Aug 09 '17 at 08:23
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/151485/discussion-between-paulw11-and-jules). – Paulw11 Aug 09 '17 at 11:05

0 Answers0