0

ASIHTTPRequest ラッパーを非常に基本的な Objective C プログラムに適用しようとしています。私はすでに必要なファイルを自分のプログラムにコピーしており、彼らのウェブサイトでそれがどのように機能するかを理解しようとして非常に頭痛の種になった後、ここに質問を投稿しようと思いました. コピーされたファイルは次のとおりです。

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

ラッパーを使用してこれらの 5 つの基本変数を http リクエスト経由で Web サーバーにエクスポートするにはどうすればよいですか?

4

1 に答える 1

0

別のサイトから答えを得ました:

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]);
于 2010-04-30T02:37:13.053 に答える