I am working on application called “Messanger”.
My task is to upload and download data from and to a server ..
I am new to this, so I don’t know how to do it.
- I want to share data with server (upload)
- I want to get data from server (download)
Can anyone help me with this ??
I need code for this.
Thanks in Advance ..
You can use classes provided in official sdk.
0) Common part.
First of all you should create
NSURLRequest. For example,NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"apple.com"]];1) Uploading data.
When you want to send some data you can use this in following way (for example, sending xml):
2) Downloading data.
Now you should start connection:
3) implement needful delegate methods. And at last you should implement that delegate methods that you would need. For example, in method
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)datayou will merge received data, in methods- (void)connectionDidFinishLoading:(NSURLConnection *)connectionand- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)erroryou should process received data.For complete list of all methods that you could implement to receive more information about your internet connection and handle different process (like authentication, response code and other) read official documentation : NSURLConnection