I have a file(XYZ.XXX) kept on my webserver. I have an iPhone client where user can input some data. After entering the data, use will click on Submit button. I send these string data to the server. Server has a component to append this data to that file (XYZ.XXX). And Server has to send back that updated file to my iPhone app. What would be the best approach to program this? I have a client app ready without communication piece. I am thinking to use http POST method to send the data as request.
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
I need to create a server component to receive this data and append with that file(XYZ.XXX). But how can the iPhone app get that开发者_运维技巧 updated file from server with the same request? Do my iPhone app has to request one more time to get the updated file? (or) With the first request itself, can it receive the updated file from the response itself?
Please advise and provide your input.
You usually want to avoid a synchronous request on the main thread as that will cause the app to appear to be locked up to the user. Have a look at apple's documentation on creating an NSURLConnection and using the delegate methods.
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html#//apple_ref/doc/uid/20001836-BAJEAIEE
精彩评论