问题
I want to save Event and Image (for event) records. I want to show uploading progress in UI. Event is little object with text and location. Image is big object with photo as UIImage.
Image record is first item in array, event is second.
I create CKModifyRecordsOperation
and set two CKRecord
objects to recordsToSave
Than I set perRecordProgressBlock
:
[operation setPerRecordProgressBlock:^(CKRecord *record, double progress) {
NSLog(@"#record: %@ progress: %f", record.recordType, progress);
}];
And perRecordCompletionBlock
:
[operation setPerRecordCompletionBlock:^(CKRecord *record, NSError *error) {
NSLog(@"#recordSaved: %@ e: %@", record.recordType, error);
}];
I expect to see a lot of rows with progress for two records like:
#record: ImageRecord progress: 0.050000
#record: ImageRecord progress: 0.100000
#record: ImageRecord progress: 0.150000
...
#record: ImageRecord progress: 1.000000
#recordSaved: ImageRecord e: (null)
#record: EventRecord progress: 0.050000
...
#record: EventRecord progress: 1.000000
#recordSaved: EventRecord e: (null)
But really in console output I see:
#record: ImageRecord progress: 0.000000
#record: ImageRecord progress: 0.447357
#record: ImageRecord progress: 1.000000
#record: ImageRecord progress: 1.000000
#recordSaved: Event e: (null)
#recordSaved: ImageRecord e: (null)
What should I do?
回答1:
The documentation for the CKModifyRecordOperation
states:
The operation object executes this block zero or more times for each record in the recordsToSave property.
So if the save action for an object takes little time, then it could happen that you won't get a progress callback. As far as I know there is no way to influence the frequency of progress notifications.
来源:https://stackoverflow.com/questions/27266589/cloudkit-records-saving-progress