5

我正在将图像处理到 iCloud 存储。使用 我正在实施的这个链接示例代码。但在这里我使用网格视图来显示图像。对于网格视图,我正在使用AQGridView示例。现在我在实现这个时遇到了一些问题。

我的项目在本地存储中运行良好,但在iCloud存储中无法运行。虽然将图像添加到网格视图中只添加了一个视图,但完成了它从视图中删除的过程,我也没有得到CloudURL

这里有一些主要代码

    - (void)processiCloudFiles:(NSNotification *)notification {

// Always disable updates while processing results
[_query disableUpdates];

[_iCloudURLs removeAllObjects];

// The query reports all files found, every time.

NSArray * queryResults = [_query results];

for (NSMetadataItem * result in queryResults) {

    NSURL * fileURL = [result valueForAttribute:NSMetadataItemURLKey];

    NSNumber * aBool = nil;

    // Don't include hidden files
    [fileURL getResourceValue:&aBool forKey:NSURLIsHiddenKey error:nil];

    if (aBool && ![aBool boolValue]) {

        [_iCloudURLs addObject:fileURL];

        NSLog(@"%@",_iCloudURLs);



    }

}

NSLog(@"Found %d iCloud files.", _iCloudURLs.count);

_iCloudURLsReady = YES;

if ([self iCloudOn]) {

    NSLog(@"%d",_objects.count);

    // Remove deleted files
    // Iterate backwards because we need to remove items form the array

    for (int i = _objects.count -1; i >= 0; --i) {

        PTKEntry * entry = [_objects objectAtIndex:i];

        if (![_iCloudURLs containsObject:entry.fileURL]) {

            [self removeEntryWithURL:entry.fileURL];
        }
    }

    NSLog(@"%@",_iCloudURLs);

    // Add new files
    for (NSURL * fileURL in _iCloudURLs) {

        [self loadDocAtURL:fileURL];
    }

    self.navigationItem.rightBarButtonItem.enabled = YES;

}

if (_moveLocalToiCloud) {

    _moveLocalToiCloud = NO;
    [self localToiCloudImpl];

}
else if (_copyiCloudToLocal) {

    _copyiCloudToLocal = NO;
    [self iCloudToLocalImpl];

}

[_query enableUpdates];

 }

我还展示了我的应用程序的控制台流程,请帮助我

 2013-02-19 13:29:26.159 XXXX[337:907] iCloud available at: file://localhost/private/var/mobile/Library/Mobile%20Documents/XXXXX~com~XXXX~XXXX/
 2013-02-19 13:29:32.847 XXXX[337:907] No longer watching iCloud dir...
 2013-02-19 13:29:32.849 XXXX[337:907] Starting to watch iCloud dir...
 2013-02-19 13:29:33.002 XXXX[337:907] Found 0 iCloud files.
 2013-02-19 13:29:33.004 XXXX[337:907] local => iCloud impl
 2013-02-19 13:29:38.697 XXXX[337:907] Want to create file at file://localhost/private/var/mobile/Library/Mobile%20Documents/XXXX~com~XXXX~XXXX/Documents/iBoast_Art_Soodu.ibt
 2013-02-19 13:29:38.781 XXXX[337:907] File created at file://localhost/private/var/mobile/Library/Mobile%20Documents/XXXX~com~XXXX~XXXX/Documents/iBoast_Art_Soodu.ibt
 2013-02-19 13:29:38.790 XXXX[337:907] load table
 2013-02-19 13:30:38.563 XXXX[337:907] button index: 1
 2013-02-19 13:30:41.595 XXXX[337:907] iCloud available at: file://localhost/private/var/mobile/Library/Mobile%20Documents/XXXX~com~XXXX~XXXX/
 2013-02-19 13:30:41.607 XXXX[337:907] No longer watching iCloud dir...
 2013-02-19 13:30:41.612 XXXX[337:907] Starting to watch iCloud dir...
 2013-02-19 13:30:41.780 XXXX[337:907] Success to close file://localhost/private/var/mobile/Library/Mobile%20Documents/XXXX~com~XXXX~XXXX/Documents/iBoast_Art_Soodu.ibt
 2013-02-19 13:30:41.790 XXXX[337:907] load table
 2013-02-19 13:30:42.011 XXXX[337:907] Found 0 iCloud files.
4

1 回答 1

0

我对此没有权威的答案,但我肯定会怀疑这是一个时间问题。我希望看到一些委托操作继续了解 iCloud 项目何时上传。

我也会改进你的日志记录。线

NSLog(@"%@",_iCloudURLs);

应该有更好的格式。没有这个,我不能确定,但​​看起来这条线永远都达不到。

于 2014-03-09T19:39:43.227 回答