ASIHttpRequest のエンコーディングに問題があります。URL を取得すると、エンコーディングの問題を除いて、データは完全に返されます。
これは私のコードです:
- (void)fetchGamesForCategory
{
NSString *url_string = [[NSString alloc] initWithFormat:url_match, theCategory._id];
NSURL *url = [NSURL URLWithString:url_string];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request startSynchronous];
NSError *error = [request error];
if (!error) {
NSString *response = [request responseString];
NSLog(@"response: %@", response);
NSData *data = [response dataUsingEncoding:NSUTF8StringEncoding];
NSString *errorDesc = nil;
NSPropertyListFormat format;
NSDictionary * dict = (NSDictionary*)[NSPropertyListSerialization
propertyListFromData:data
mutabilityOption:NSPropertyListMutableContainersAndLeaves
format:&format
errorDescription:&errorDesc];
NSDictionary *categoryListPathDictionary = [[NSDictionary alloc] initWithDictionary:dict];
categoryMatchList *categoryMatchListFile = [[[categoryMatchList alloc] initWithDictionary:categoryListPathDictionary] retain];
matchArray = [categoryMatchListFile getMatchListXmlSet];
[self loadPage];
}
}
そして、これが私の結果です:
2010-09-28 21:49:35.970 oddsApp[46429:190f] response: <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist>
<dict>
<key>matches</key>
<array>
<dict>
<key>name</key>
<string>Gais - Häcken</string>
<key>date</key>
<string>2010-09-29 18:00</string>
<key>id</key>
<string>156</string>
<key>odds</key>
<dict>
<key>1</key>
<string>2.6</string>
<key>X</key>
<string>3.28</string>
<key>2</key>
<string>2.862</string>
</dict>
</dict>
</array>
</dict>
</plist>
ご覧のとおり、エンコーディングは<string>Gais - Häcken</string>
でめちゃくちゃになっていますが、ブラウザでページを表示するときは正しいです。
誰かが何が悪いのか知っていますか?