2013-05-08 5 views
1

AFNetworking의 Im noob이 지금 학습했습니다. URL에서 파일을 다운로드하고 내 앱 (문서 폴더)에 저장하고 싶지만 작동하지 않습니다. 하나의 버튼을 클릭하면 다운로드가 시작됩니다.AFNetwotking을 사용하여 내 앱의 URL에서 다운로드 할 수 없습니다.

이 다운로드 파일에 대한 내 코드입니다 : 버튼을 클릭 나에게이 마사지 = '다운로드 시작'을 가지고 있지만, 내가 왜 '성공적 %를 @로 파일을 다운로드'보여 그나마이 코드에서

- (IBAction)downloads:(id)sender 
{ 
    NSLog(@"start downloads"); 
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://192.168.1.100/mamal/filemanager.php"]]; 

    AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *path = [paths objectAtIndex:0]; 

    operation.outputStream = [NSOutputStream outputStreamToFileAtPath:[path stringByAppendingPathComponent:@"filemanager.php"] append:NO]; 

    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { 
     NSLog(@"Successfully downloaded file to %@", path); 
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 
     NSLog(@"Error: %@", error); 
    }]; 
} 

은? 내 코드가 완성되지 않았습니까 ???

답변

2

작업을 시작하지 않았습니다. 다음 줄을 사용하여 작업을 시작하십시오.

[operation start]; 
관련 문제