CloudKit records saving progress

隐身守侯 提交于 2019-12-20 04:56:02

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!