2014-08-28 76 views
0

Im新的Dropbox Core API。以前我有一些使用NSURLSession在樹屋課程上調用instagram api的經驗。但是我卡在這裏。 Iv叫做方法DropBox核心API下載UICollectionView的圖像

- (void)restClient:(DBRestClient *)client loadedMetadata:(DBMetadata *)metadata { 
if (metadata.isDirectory) { 
    NSLog(@"Folder '%@' contains:", metadata.path); 
    for (DBMetadata *file in metadata.contents) { 

     [self.pathsArray addObject:file.path]; 

     NSLog(@"----%@", pathsArray); 
    } 


} 

//reloads view to see images 
[self.collectionView reloadData]; 



} 

哪給了我一個文件路徑位置的數組。然後我寫了

NSString *paths = [[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:[self.filePaths lastPathComponent]]]; 


`for (NSString *file in self.filePaths) { 

    [self.restClient loadFile:file intoPath:paths]; 
}`  

正確但其下載圖像,因爲加載文件方法返回null我不確定如何創建下載圖像的陣列,我UICollectionViews單元格中顯示?

回答

1

在Dropbox的iOS版核心SDK的loadFile方法說:

/* Loads the file contents at the given root/path and stores the result into destinationPath */ 
- (void)loadFile:(NSString *)path intoPath:(NSString *)destinationPath; 

這意味着下載的內容(在path上的Dropbox文件)在本地路徑destinationPath保存到本地文件系統。

您可以使用該委託的方法,知道什麼時候這樣做:

- (void)restClient:(DBRestClient*)client loadedFile:(NSString*)destPath; 

要獲取下載的文件內容,一旦你已經通知它完成,你需要閱讀從下載的文件本地文件系統。例如,您可以使用NSString stringWithContentsOfFile:encoding:error或下一步的相關步驟加載它。

+0

非常感謝! – CURATOR 2014-08-29 08:38:55