2010-12-03 1 views
1

Hello 아무도 내가이 snippent를 iOS 4.2로 업데이트하는 데 도움을 줄 수 있습니까?stringWithContentsOfURL 가치 하락, 4.2로 업데이트하는 데 도움이됩니까?

업데이트가 필요한 유일한 부분은 다음과 같습니다. 나머지는 잊어 버릴 수 있습니다.

NSData *htmlData = [[NSString stringWithContentsOfURL:[NSURL URLWithString: @"http://www.objectgraph.com/contact.html"]] dataUsingEncoding:NSUTF8StringEncoding]; 

"stringWithContentsOfURL"이 deprechiated되었습니다. 그래서 업데이트 된 버전은 무엇입니까?

감사

답변

1

당신은

+ (id)stringWithContentsOfURL:(NSURL *)url encoding:(NSStringEncoding)enc error:(NSError **)error 

를 사용하고 그런 식으로 사용합니다.

NSData *htmlData = [[NSString stringWithContentsOfURL:[NSURL URLWithString: @"http://www.objectgraph.com/contact.html"]] encoding:NSUTF8StringEncoding error:nil]; 
+0

에 의해

NSData *htmlData = [[NSString stringWithContentsOfURL:[NSURL URLWithString: @"http://www.objectgraph.com/contact.html"]] dataUsingEncoding:NSUTF8StringEncoding]; 

은 위의 코드에 그 연결 바꾸기? "+"와 함께 ??? 당신의 도움을 주셔서 감사합니다. –

+0

"+"가 무엇을 의미하는지 모른다면 위의 코드를 어떻게 작성했는지 모르겠습니다 ... http://developer.apple.com/library/mac/#referencelibrary/GettingStarted/Learning_Objective-C_A_Primer/ – gcamp

+0

내 무지를 변명해라, 이것은 slapdash 응용 프로그램이다. 나는 객관적인 c에 정통하지 않고 단지 예제를 통해 배우고 있습니다. –