2010-04-25 6 views
0

아주 기본적인 Objective C 프로그램에 ASIHTTPRequest 랩퍼를 적용하려고합니다. 나는 이미 필요한 파일들을 내 프로그램에 복사했고, 웹 사이트를 통해 어떻게 작동하는지 알아 내려고 극심한 두통을 쏟은 후에 여기에 질문을 올리겠다고 생각했다. 복사 파일은 있었다 :Mac 용 ASIHTTPRequest 랩퍼 사용

ASIHTTPRequestConfig.h 
ASIHTTPRequestDelegate.h 
ASIProgressDelegate.h 
ASIInputStream.h 
ASIInputStream.m 
ASIHTTPRequest.h 
ASIHTTPRequest.m 
ASIFormDataRequest.h 
ASIFormDataRequest.m 

내 프로그램은 매우 기본적인 :

#import <Foundation/Foundation.h> 

int main (int argc, const char * argv[]) { 
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 

// Defining the various variables. 
char firstName[20]; 
char lastName[20]; 
char rank[5]; 
int leaveAccrued; 
int leaveRequested; 

// User Input. 
NSLog (@"Please input First Name:"); 
scanf("%s", &firstName); 

NSLog (@"Please input Last Name:"); 
scanf("%s", &lastName); 

NSLog (@"Please input Rank:"); 
scanf("%s", &rank); 

NSLog (@"Please input the number leave days you have accrued:"); 
scanf("%i", &leaveAccrued); 

NSLog (@"Please input the number of leave days you are requesting:"); 
scanf("%i", &leaveRequested); 

// Print results. 
NSLog (@"Name: %s %s", firstName, lastName); 
NSLog (@"Rank: %s", rank); 
NSLog (@"Leave Accrued: %i", leaveAccrued); 
NSLog (@"Leave Requested: %i", leaveRequested); 


    [pool drain]; 
    return 0; 
} 

가 어떻게 HTTP 요청을 통해 웹 서버에이 5 개 기본적인 변수를 내보낼 래퍼를 사용합니까?

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://asi/ASIHTTPRequest/tests/post-data"]]; 
[request setPostValue:[NSString stringWithCString:firstName encoding:NSUTF8StringEncoding] forKey:@"firstName"]; 
[request setPostValue:[NSString stringWithFormat:@"%i",leaveAccrued] forKey:@"leaveAccrued"]; 
[request startSynchronous]; 
NSLog(@"%@",[request responseString]); 
:

답변

0

다른 사이트에서 대답을 얻었다