views:

54

answers:

1

I have a buddy who is building the web server side of things and he needs my iphone app to send him a request. I don't have any experience in this type of programming so it is proving to be a bit difficult.

I am trying to do a simple request that looks like this:

        ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:
[NSURL URLWithString:@"http://thewebserverURL"]];
        [request setPostValue:[NSString stringWithCString:txtName
encoding:NSUTF8StringEncoding] forKey:@"field02"];
        [request setPostValue:[NSString stringWithCString:txtTodaysDate
encoding:NSUTF8StringEncoding] forKey:@"field05"];
        [request startSynchronous];
        NSLog(@"%@",[request responseString]);

I am getting 2 errors on each of the "request setPostValue" lines that read "Passing argument 1 of stringWithCString: encoding from incompatible pointer type."

txtName and txtTodaysDate are both NSStrings. What am I doing wrong?

+1  A: 

The setPostValue parameter is supposed to be a NSString, so you can just pass txtName and txtTodaysDate directly. stringWithCString is used for converting a NUL-terminated C string to a NSString. Thus, the first parameter is a char *.

Matthew Flaschen