HTTPRequestAppDelegate.m
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// 접속할 주소 설정
NSString *url = @"http://your.webpage.url";
// HTTP Request 인스턴스 생성
HTTPRequest *httpRequest = [[HTTPRequest alloc] init];
// POST로 전송할 데이터 설정
NSDictionary *bodyObject = [NSDictionary dictionaryWithObjectsAndKeys:@"eye",@"name",@"http://theeye.pe.kr", @"home", nil];
// 통신 완료 후 호출할 델리게이트 셀렉터 설정
[httpRequest setDelegate:self selector:@selector(didReceiveFinished:)];
// 페이지 호출
[httpRequest requestUrl:url bodyObject:bodyObject];
[window makeKeyAndVisible];
}
HTTPRequest.h
#import <Foundation/Foundation.h>
@interface HTTPRequest : NSObject
{
NSMutableData *receivedData;
NSURLResponse *response;
NSString *result;
id target;
SEL selector;
}
- (BOOL)requestUrl:(NSString *)url bodyObject:(NSDictionary *)bodyObject;
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)aResponse;
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data;
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;
- (void)connectionDidFinishLoading:(NSURLConnection
…