CloudKit记录保存进度 [英] CloudKit records saving progress

查看:81
本文介绍了CloudKit记录保存进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要保存事件和图像(用于事件)记录。我想在UI中显示上传进度。
事件是带有文本和位置的小对象。
图像是带有UIImage的大对象。

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.

我创建 CKModifyRecordsOperation 并将两个 CKRecord 对象设置为 recordsToSave

I create CKModifyRecordsOperation and set two CKRecord objects to recordsToSave

我设置了 perRecordProgressBlock

[operation setPerRecordProgressBlock:^(CKRecord *record, double progress) {
    NSLog(@"#record: %@ progress: %f", record.recordType, progress);
}];

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)

我该怎么办?

推荐答案

CKModi的文档fyRecordOperation 状态:
操作对象对recordsToSave属性中的每个记录执行此块零次或多次。

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.

这篇关于CloudKit记录保存进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆