Reputation: 814
I need to post two pieces of data at the same time to a WEB server One piece is image data contined in a UIImage and the other is audio data contained in a caf file.
I am asking for an example showing how to post this data.
Upvotes: 0
Views: 447
Reputation: 104065
You need to use NSURLConnection
. That takes an NSURLRequest
as a parameter. There’s also a descending class called NSMutableURLRequest
where you can set the request body and method.
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:…];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:/* NSData */];
NSURLConnection *connection = [NSURLConnection
connectionWithRequest:request delegate:…];
[connection doSomething];
There are already questions on Stack Overflow on getting NSData
representation of an UIImage
, see the UIImageJPEGRepresentation
function for example.
Upvotes: 1