2013-02-11 51 views
1

此代碼完美地在模擬器上工作,寫出文件。在模擬器上的網絡工作不適用於iPhone設備

但是在iPhone上,它不會寫出文件。

DLog(@""); 

timeStart = [NSDate date]; 


NSURL *url = [NSURL URLWithString:SAT_URL]; 
NSURLRequest *request = [NSURLRequest requestWithURL:url]; 

AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; 

NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:FILE_NAME]; 
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:path append:NO]; 

[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { 

    DLog(@"updated words to: %@",path); 
    //DLog(@"response: %@",responseObject); 

    [self processWords]; 

} failure:^(AFHTTPRequestOperation *operation, NSError *error) { 

    // Deal with failure 
}]; 

[operation start]; 

rawWords和線條都是空的設備:

NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:FILE_NAME]; 
NSString *rawWords = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil]; 
NSArray *lines = [rawWords componentsSeparatedByString:@"\n"]; 

它使用AFNetworking lib和我已經嘗試獲取來自不同的託管文件。

我在做什麼錯?

+1

是連接到互聯網的設備?只是檢查。 – Bergasms 2013-02-11 02:58:05

+0

是的,它是...。 – stackOverFlew 2013-02-11 03:01:18

回答

相關問題