Shouldn't this callback receive an array of NSErrors?

Ask a question here. It may wind up in the FAQ on the plugin homepage.
pistoleta
Posts: 16
Joined: Fri Nov 06, 2020 12:11 pm

Shouldn't this callback receive an array of NSErrors?

Post by pistoleta »

Image

I was trying to implement the batch record modification but I see the callback is just receiving 1 NSError, shouldn't be an array ?

admin
Site Admin
Posts: 49
Joined: Thu Mar 19, 2020 8:52 pm

Re: Shouldn't this callback receive an array of NSErrors?

Post by admin »

You'd think right? But no - this callback only has a single error. This is true for all batch operations in cloudkit.
This matches the API here https://developer.apple.com/documentati ... guage=objc

When you use batch operations, or any operation that takes an array of records or recordIds. If there is some issue, you will usually recieve an error with an error code "CKPartialFailure" as the error.

But there is per-record error information. You have a few options for retrieving it.

1.) The specific error that triggered this failure will be contained in the user-info dictionary. It's in another dictionary under the key "CKPartialErrorsByItemIDKey". I may need to update the NSError class to get you access to this dictionary. I'll have a check and report back to you.

2.) The Per-Record Completion block is invoked for each record. The error in this callback will be more specific. It'll be the same error that ends up in the "PartialErrorsByItemID" dictionary. One caveat is that the per-record callbacks are NOT invoked if there is some kind of network failure (user is not connected to the internet). So this is a very unreliable method.

pistoleta
Posts: 16
Joined: Fri Nov 06, 2020 12:11 pm

Re: Shouldn't this callback receive an array of NSErrors?

Post by pistoleta »

Okay, understood.
For the moment I was just messing with batched operations to see if they worked fine but it's not like we need them, at least for now.
But it's good to know.
Thanks!

ShannonVag
Posts: 1
Joined: Tue Aug 17, 2021 4:25 am

-

Post by ShannonVag »

I apologise, but, in my opinion, you are not right. I can prove it. Write to me in PM, we will talk.
liqiuskin-cream site

Post Reply