nsurlconnection

NSURLConnection, NSURLRequest, untrusted cert and user authentication

北慕城南 提交于 2019-12-09 03:06:40
问题 Morning Everyone, I've been attempting to write an application that does some GETs from a remote Web Service that requires authentication. My main problem is that the majority of these remote servers (and there are a lot of them) don't have valid certificates. I've got code to accept the invalid certificate and code to respond to the challenge with the correct uname & pass (below). The problem I'm having is getting the two to play together. I can't seem to find a way to send the challenge

lock screen interrupts NSURLConnection

空扰寡人 提交于 2019-12-08 23:56:32
问题 I'd like to know what's happening behind the scenes when the user locks and unlocks the iPad screen. I have an app that downloads files using NSURLConnection and the downloads fail with a SOAP error ("A server with the specified hostname could not be found"), but not when the user locks the screen, but when it unlocks it. Regardless of the fact when the error pops up, the download never finishes. Any ideas why and what could be done about it ? NSMutableURLRequest* request =

Reusing an instance of NSURLConnection

蓝咒 提交于 2019-12-08 19:51:26
问题 I'm using an instance of NSURLConnection on the iPhone to request data from a server, managed by a delegate as usual. The requests are quite frequent (maybe once every 2 minutes say) and have a common and fixed URL. Rather than seeing the good instance of NSURLConnection being released after each download and then a new one being created: Is there any worth in retaining the first connection and reusing it? (I'd hope so, one good authentication should be worth a thousand.) If so, how do I

Posting JSON data to server

一曲冷凌霜 提交于 2019-12-08 13:57:47
I am trying to post and JSON data to server. My JSON is: { “username”:”sample”, “password” : “password-1” } The way I am sending it to server is: NSError *error; NSString *data = [NSString stringWithFormat:@"{\"username\":\"%@\",\"password\":\"%@\"}",_textFieldUserName.text,_textFieldPasssword.text]; NSData *postData = [data dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSData *jsonData = [NSJSONSerialization JSONObjectWithData:postData options:0 error:&error]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setURL:[NSURL URLWithString:@"My URL"

NSURLConnection sendAsynchronousRequest:queue:completionHandler not working in iOS 4.3

筅森魡賤 提交于 2019-12-08 13:31:16
问题 I am using [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) in my app. By using this my app is terminated in iOS 4.3 but it is working fine in iOS 5.0. How to use this in iOS 4.3 can any one help me. 回答1: Here's a full implementation that works for me. Feel free to rename it and add as a category on NSURLConnection , or just add it as a local method in the class you're working in. -

NSURL delegate didReceiveData method not called

牧云@^-^@ 提交于 2019-12-08 12:37:30
问题 I know this has been discussed in a lot of other posts but I need to post it because those threads have not helped me unfortunately. I am trying to connect to a rails server which returns some data in JSON format in response to a GET request.I have implemented the four methods for NSConnectionDataDelegate as listed below #pragma mark - #pragma mark NSURLConnectionDataDelegate -(void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { NSLog(@

Encoding UIImage to Base64 string not working when transferred to server

孤者浪人 提交于 2019-12-08 11:08:30
问题 Encoding an UIImage as a Base64 string works on the device, but transferring the string to the server somehow corrupts the string and prevents the server from successfully decoding the image. Any suggestions on the problem? // Define params params["thumbnail_base64"] = imageToBase64(blockSet.thumbnailURL) ... // Convert params -> query string let postString = buildQueryString(params) // Define upload URL let uploadURL = NSURL(string: RootURL + UploadFilePath)! // Hit server let request =

Swift: How to decode result from api which is being returned as a string or as a string of array?

末鹿安然 提交于 2019-12-08 10:58:19
问题 I am using NSUrlConnection and Codable library of Apple. I am using a web API to signup new users for my application. The API returns a status and a message (in json which i map to a model). This is my model class: Struct SignUpResult { let message: String let status: String } Struct SignUpParams { let name: String let email: String let mobile_no: String let password: String } If the user gave all the parameters correctly then the message is returned as a string. Like this: { "status": "OK",

iPhone SDK: How to send data to a server over the internet?

谁说胖子不能爱 提交于 2019-12-08 09:50:33
i wrote a gps-application for the iphone and it all works fine but now i want to send the latitude and longitude to a server over the internet using the most simple way... I have a url from the server in which there are parameters for latitude and longitude. Also i want the lat. and long. to be sent every 90 seconds or so. How exactly is all of this done? Any help is much appreciated, thanks in advance! NSURL *cgiUrl = [NSURL URLWithString:@"http://yoursite.com/yourscript?yourargs=1"]; NSMutableURLRequest *postRequest = [NSMutableURLRequest requestWithURL:cgiUrl]; /* leave the rest out if just

iPhone unexpected duplication of TCP packets on different ports

让人想犯罪 __ 提交于 2019-12-08 07:53:04
问题 I'm running this simple asio-based program: Address address = Address::from_string(host); Tcp::endpoint ep(address, port); Tcp::resolver::iterator endpoint_iterator = resolver.resolve(ep); Tcp::socket socket(io_service); asio::connect(socket, endpoint_iterator); Everything works fine on my host machine, but when this program run under iOS (both iphone and iphonesimulator) my sniffer detect some unexpected packets: # client: 192.168.1.10, server: 192.168.1.100 # everything fine... 5.359761000