- (NSString *) GetHtmlData:(char *)homepage{
NSError *error;
NSURLResponse *response;
NSData *dataReply;
NSString *stringReply;
NSString *getUrl = [NSString stringWithFormat:@"%s",homepage];
NSMutableURLRequest *request =
[NSMutableURLRequestrequestWithURL: [NSURL URLWithString: getUrl]];
[request setHTTPMethod: @"PUT"];
[request setHTTPBody: [[NSString stringWithString:@"test"]dataUsingEncoding:
NSUTF8StringEncoding]];
dataReply = [NSURLConnection
sendSynchronousRequest:requestreturningResponse:&response
error:&error];
stringReply = [[NSString alloc]
initWithData:dataReplyencoding:NSUTF8StringEncoding];
return stringReply;
}
위의 소스는 HTML이 UTF8로 인코딩이 되어 있을 경우 무리 없이 가져오며, 만약 euc-kr로 작성이 되어 있다면 붉은색으로 코딩된 부분은 -2147481280 으로 바꾸어 주면 웹 데이터를 가져올수 있다.
'개발 > Objective-C' 카테고리의 다른 글
* <- 이넘의 정체 (0) | 2010.08.31 |
---|---|
[Objective-C] Convert NSString to char * (0) | 2010.08.29 |
[Objective-C] String Function in Object-C (0) | 2010.08.29 |
[Objectiv-C] Google Code에 있는 ParseKit을 연결하기 (0) | 2010.08.29 |
[Objective-C] tokenizerWithString in ParseKit (0) | 2010.08.29 |