当我调用 DBRESTClient 将文件下载到给定路径时,API 不会调用加载函数。
例如:
- (void) downloadFiles:(NSMutableArray *)files
{
NSLog(@"%@", files);
itemsToBeDownloaded = [[NSMutableArray alloc] initWithArray:files];
restClient = [self restClient];
for (NSString *string in files)
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"/Dropbox%@", string]];
[restClient loadFile:string intoPath:filePath];
}
}
打印files
退货(
"/Blank.pdf"
)
打印string
退货/Blank.pdf
打印filePath
退货/var/mobile/Applications/0C506400-7142-41E2-9F3D-0965985CED9E/Documents/Dropbox/Blank.pdf
因此调用该函数并知道要下载的文件及其路径。
但是,当我打电话时[restClient loadFile:string intoPath:filePath];
,什么也没有发生。我有委托方法:
- (void) restClient:(DBRestClient *)client loadedFile:(NSString *)destPath
{
NSLog(@"Called!");
}
- (void) restClient:(DBRestClient *)client loadedFile:(NSString *)destPath contentType:(NSString *)contentType
{
NSLog(@"Called!");
}
- (void) restClient:(DBRestClient *)client loadedFile:(NSString *)destPath contentType:(NSString *)contentType metadata:(DBMetadata *)metadata
{
NSLog(@"%@", destPath);
NSLog(@"%@", contentType);
NSLog(@"%@", metadata);
}
- (void) restClient:(DBRestClient *)client loadFileFailedWithError:(NSError *)error
{
NSLog(@"Error downloading file: %@", error);
}
不产生任何Called!
语句。RestClient 似乎没有下载数据。
另一个注意事项:restClient = [self restClient];
确实返回了一个有效的 DBRESTClient,所以我知道它是有效的。但是,没有调用加载文件的调用。
是否有特定原因没有拨打电话loadFile:
?我让它加载元数据就好了。
编辑:调用 loadMetadata: atstring
不调用loadMetadata委托方法。
编辑 2:下面的代码列出了文件数组的声明方式:
- (void) downloadFiles
{
NSMutableArray *filesToDownload = [[NSMutableArray alloc] init];
for (int i = 0; i < [[itemsToDownload allKeys] count]; ++i)
{
for (NSString *string in [itemsToDownload objectForKey:[[itemsToDownload allKeys] objectAtIndex:i]])
{
[filesToDownload addObject:[NSString stringWithFormat:@"%@%@", [[itemsToDownload allKeys] objectAtIndex:i], string]];
}
}
[dropboxController downloadFiles:filesToDownload];
}