막연한 대답 이외의 정보를 제공하지 않았지만 여기에 몇 가지 옵션이 있습니다.
가장 중요한 것은 결과를 인쇄해야하는 "error
"매개 변수가 있다는 것입니다. 또한 NSString 클래스에서 사용할 수있는 약간 더 나은 API가 있습니다.
은 이런 식으로 코드를 변경
: 지금 대신 STHTTPRequest을 사용하고
NSError *error = NULL;
NSStringEncoding actualEncoding;
// variable names in Objective-C should usually start with lower case letters, so change
// URL in your code to "url", or even something more descriptive, like "urlOfOurString"
NSString *string = [[NSString alloc] initWithContentsOfURL:urlOfOurString usedEncoding:&actualEncoding error:&error];
if(string)
{
NSLog(@"hey, I actually got a result of %@", string);
if(actualEncoding != NSUTF8StringEncoding)
{
// I also suspect the string you're trying to load really isn't UTF8
NSLog(@"and look at that, the actual encoding wasn't NSUTF8StringEncoding");
}
} else {
NSLog(@"error when trying to fetch from URL %@ - %@", [urlOfOurString absoluteString], [error localizedDescription]);
}
미안하지만 내가 충분히 명확하지는 않지만 실제로 그렇습니다. 실제로는 UTF8입니다. 이것이 프로세스를 더 안정하게 만들 것인지 시도해 볼 것입니다. 서버 측에서 문제가 될 수 있는지 궁금합니다. – Mathias