理由はわかりませんが、私がすることはすべてこの問題を解決することはできません。サーバーからJSONデータを取得できません。
これは私が取得しているエンコードされたNSStringです:
http%253A%252F%252Fwww.doctors.co.il%252Fmobile%252Fforum%252Fforum-4863%253Fpage%253D12%252F
これは私のコードです:
- (NSString *)urlencode {
NSMutableString *output = [NSMutableString string];
const unsigned char *source = (const unsigned char *)[self UTF8String];
int sourceLen = strlen((const char *)source);
for (int i = 0; i < sourceLen; ++i) {
const unsigned char thisChar = source[i];
if (thisChar == ' '){
[output appendString:@"+"];
} else if (thisChar == '.' || thisChar == '-' || thisChar == '_' || thisChar == '~' ||
(thisChar >= 'a' && thisChar <= 'z') ||
(thisChar >= 'A' && thisChar <= 'Z') ||
(thisChar >= '0' && thisChar <= '9')) {
[output appendFormat:@"%c", thisChar];
} else {
[output appendFormat:@"%%%02X", thisChar];
}
}
return output;
}
- (void)startLoadingApplicationDataOf
{
NSString *raw = @"http://www.doctors.co.il/mobile/forum/forum-4863?page=12/";
NSString *safestring = [raw urlencode];
NSURL *requestURL = [NSURL URLWithString:safestring];
[self startRequest:requestURL];
}
- (void)startRequest:(NSURL *)requestURL
{
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:requestURL];
[request setDidFinishSelector:@selector(requestCompleted:)];
[request setDidFailSelector:@selector(requestError:)];
[request setDelegate:self];
[request startAsynchronous];
[request setTimeOutSeconds:20.0f];
}
私は何が間違っているのですか?JSONを返す他のWebアドレスでは完全に機能しますが、これでは次のエラーが発生し続けます。
Failed to load data with error: Error Domain=ASIHTTPRequestErrorDomain Code=6 "Unable to start HTTP connection" UserInfo=0x8bc72b0 {NSLocalizedDescription=Unable to start HTTP connection}