2011-01-02 2 views
3

이 URL의 텍스트 파일 내용을 가져 오려고했지만 작동하지 않습니다. 어떤 도움?표시 할 URL의 텍스트 파일 내용 iphone

NSURL *url = [NSURL URLwithString:@"http://haproxy.1wt.eu/download/1.9/keep-alive/keep-alive.txt"]; 
NSString *content = [NSString stringWithContentsOfURL:url encoding:NSASCIIStringEncoding]; 
NSLog(content); 

실제 텍스트 파일은 20 단어가 될 것입니다. 그러나 이것은 단지 예일뿐입니다.

내가 잘못 했나요? 또는 훨씬 더 힘들 수 있습니까? 당신은 가까웠다

답변

11

... URLWithString에서
자본 W 오류로
NSError의 variabel :있는 NSString
의 매개 변수 이 그런 다음 당신은 또한 좋은이다 ASIHTTPRequest를 사용하여 시도해야

NSURL *url = [NSURL URLWithString:@"http://haproxy.1wt.eu/download/1.9/keep-alive/keep-alive.txt"]; 
NSError* error; 
NSString *content = [NSString stringWithContentsOfURL:url encoding:NSASCIIStringEncoding error:&error]; 

작동합니다 CFNetwork API 래퍼

+0

환상적! 고마워 :) 일 했어! – user370507