2013-05-15 2 views
1

DBRestClient를 호출하여 지정된 경로로 파일을 다운로드하면 API가 로딩 기능을 호출하지 않습니다. filePath 반환 그래서 함수가 호출Dropbox iOS Core SDK가 파일을 다운로드하지 않습니다.

/var/mobile/Applications/0C506400-7142-41E2-9F3D-0965985CED9E/Documents/Dropbox/Blank.pdfstring 반환 /Blank.pdf

인쇄 ( "/Blank.pdf" )

인쇄를 반환하고 파일과 경로를 알고 files

- (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]; 
    } 
} 

인쇄 : 예를 들어

' 다운로드 할 수 있습니다.

그러나 [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에 전화 :

편집

string에서이 하지 호출 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]; 
} 
+0

기다림 나는 혼란 스럽다. '불렀다! 성명서 '가 나온다. 그래서 당신의 기록에는 정확히 무엇이 보이나요? –

+0

'2013-05-15 12:22:43.868 XXX [50112 : 7a23] 파일 : ( "/Blank.pdf" )' 'purgeIdleCellConnections : 퍼지 할 사람을 찾음 = 0x1d5f14f0' –

+0

보관 용 계정에 Blank.pdf가 어디에 있습니까? api 샌드 박스 폴더가 있습니까? 아니면 전체 dropbox를 사용합니까? –

답변

4

그래서 내가 알아 낸 전체 문제. 밖으로, 당신은 배경 스레드에서 나머지 클라이언트 메서드를 호출 할 수 없습니다, 그것은 메인 스레드에서 호출해야합니다.

+0

DBRestClient가 내부적으로 NSURLConnection을 사용하고 NSURLConnection (비동기 방식으로 사용됨)과 주 스레드 사이의 관계에 대한 자세한 내용은이 질문을 참조 할 수 있습니다. http://stackoverflow.com/questions/10535201/nsurlconnection- needs-a-nsrunloop-to-execute –

0

먼저 당신이 드롭 박스에 잘못된 경로를 호출 생각하지만 이벤트가 다음 오류 메시지가 나타날 수 있어야합니다.

restClient이 잘못된 경로로도 위임 방법을 반환하면 - (void)restClient:(DBRestClient*)client loadFileFailedWithError:(NSError*)error이 호출되었을 것입니다.

귀하의 restClient이 올바르게 초기화 된 것으로 의심됩니다.

#import <DropboxSDK/DropboxSDK.h> 
@property (nonatomic, strong) DBRestClient *restClient; 

in.your.m 파일 : 당신의 .H 파일에

다음

#import <DropboxSDK/DropboxSDK.h> 
@synthesize restClient = _restClient; 
- (DBRestClient *)restClient { 
    if (!_restClient) { 
     _restClient = 
     [[DBRestClient alloc] initWithSession:[DBSession sharedSession]]; 
     _restClient.delegate = self; 
    } 
    return _restClient; 
} 

전화를 시도하여

[[self restClient] loadFile:@"string" intoPath: @"pathstring" ];

+0

최악의 부분은 내가 거기에 모든 것을 가지고 있다는 것입니다. 앱은 모든 보관 용 계정 작업을 처리하는 하나의 중앙 보관 용 보관함 스크립트를 사용합니다. 이 스크립트에는 코드가 있으며 다른보기에서 작동합니다. 어떤 이유로 그것은 하나의보기에서 작동하지 않습니다. –

+0

dropboxController가 restclient를 호출 중이므로 전체 프로젝트를 보지 않고도 말할 수 없지만 문제에 대한 올바른 대답을 얻을 수 있기를 바랍니다. –

관련 문제