开发者

ASIHTTPRequest wrapper usage for Macs

I am trying to apply the ASIHTTPRequest wrapper to a very basic Objective C program. I have already copied over the necessary files into my program and after giving myself an extreme headache trying to figure out how it works through their website I thought I would post a question on here. The files copied over were:

ASIHTTPRequestConfig.h
ASIHTTPRequestDelegate.h
ASIProgressDelegate.h
ASIInpu开发者_StackOverflow社区tStream.h
ASIInputStream.m
ASIHTTPRequest.h
ASIHTTPRequest.m
ASIFormDataRequest.h
ASIFormDataRequest.m

My program is very basic:

#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;
}

How do I utilize the wrapper to export these 5 basic variables to a web server via an http request?


Got the answer from another site:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜