nsurlconnection

Error message : [MC] Reading from public effective user settings & [MC] System group container for systemgroup.com.apple.configurationprofiles path is

时间秒杀一切 提交于 2019-12-05 21:49:55
问题 When I use the following code, I have error messages : [NSURLConnection sendAsynchronousRequest:request queue:myQueue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; NSLog(@"response status code: %ld, error status : %@", (long)[httpResponse statusCode], error.description); if ((long)[httpResponse statusCode] >= 200 && (long)[httpResponse statusCode]< 400) { // do stuff [self requestFunction]; //Web

NSUrlRequest from curl for stripe

≡放荡痞女 提交于 2019-12-05 21:30:17
I need to make a http post request using the following instructions: curl https://api.stripe.com/v1/tokens \ -u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \ -d "bank_account[country]=US" \ -d "bank_account[routing_number]=110000000" \ -d "bank_account[account_number]=000123456789" I have no idea how to go from curl to NSUrlrequest, especially the -u (user?) part. The stripe SDK has left this out from their SDK and has no example on their site. Thanks EDIT:I created another answer specifically for getting a token for a bank_account. This answer was for generally how to make a call using parse's back end

Decoding partial UTF-8 into NSString

空扰寡人 提交于 2019-12-05 20:21:43
While fetching a UTF-8 -encoded file over the network using the NSURLConnection class, there's a good chance the delegate's connection:didReceiveData: message will be sent with an NSData which truncates the UTF-8 file - because UTF-8 is a multi-byte encoding scheme, and a single character can be sent in two separate NSData In other words, if I join all the data I get from connection:didReceiveData: I will have a valid UTF-8 file, but each separate data is not valid UTF-8 (). I do not want to store all the downloaded file in memory. What I want is: given NSData , decode whatever you can into an

How to download files in background mode iOS? And Network connection Lost

半城伤御伤魂 提交于 2019-12-05 20:18:13
In My App I download the audio files from the server, And the files are downloaded fine when the app is in foreground and when I clicked home button or lock button to force the app to go to background, then after some time, the download is stopped and the error comes as the 1005 network connection lost . Whats the problem? Can Anybody explain the issue? Code: NSURL *url = [NSURL URLWithString:currentURL]; NSURLRequest *theRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60]; receivedData = [[NSMutableData alloc] initWithLength:0];

Why NSURLConnection delegate methods don't get called, when using the global dispatch queue?

断了今生、忘了曾经 提交于 2019-12-05 19:44:02
When I do the following: dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, NULL), ^{ create NSURLRequest; create NSURLConnectionDelegate; create NSURLConnection; start NSURLConnection; }); The delegate's methods never get called. But when I do dispatch_async(dispatch_get_main_queue(), ^{ create NSURLRequest; create NSURLConnectionDelegate; create NSURLConnection; start NSURLConnection; }); They do get called. Why? UPD http://developer.apple.com/library/ios/#qa/qa1712/_index.html Now I do create NSURLConnection; start NSURLConnection; on the main thread. In the first case,

Synchonous SSL certificate handling on iPhone

Deadly 提交于 2019-12-05 19:36:17
I was wondering if anyone can help me understand how to add SSL certificate handling to synchronous connections to a https service. I know how to do this with asynchronous connections but not synchronous. NSString *URLpath = @"https://mydomain.com/"; NSURL *myURL = [[NSURL alloc] initWithString:URLpath]; NSMutableURLRequest *myURLRequest = [NSMutableURLRequest requestWithURL:myURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60]; [myURL release]; [myURLRequest setHTTPMethod:@"POST"]; NSString *httpBodystr = @"setting1=1"; [myURLRequest setHTTPBody:[httpBodystr

Image(or video) posting to server in Swift

ぃ、小莉子 提交于 2019-12-05 18:44:57
Hi I am posting json data to server using NSURLSession in swift as below var request = NSMutableURLRequest(URL: NSURL(string: "http://mypath.com")) var session = NSURLSession.sharedSession() request.HTTPMethod = "POST" var params2 :NSDictionary = ["email":"myemail@gmail.com"] var params :NSDictionary = ["function":"forgotPassword", "parameters":params2] var err: NSError? request.HTTPBody = NSJSONSerialization.dataWithJSONObject(params, options: nil, error: &err) request.addValue("application/json", forHTTPHeaderField: "Content-Type") request.addValue("application/json", forHTTPHeaderField:

Stop current NSURLConnection

风格不统一 提交于 2019-12-05 13:44:29
问题 Currently, I am making an NSURLConnection whenever mySearchBar.text did change. I am experiencing an issue whereby if the user enters text too quickly, The respondData gets corrupted. So, I was wondering is there a way to check whether the same NSURLConnection is still loading? If yes, How do I drop the current connection and start a new one? 回答1: Add a property for that NSURLConnection and before starting new connection, do: [self.conn cancel]; self.conn = nil; 回答2: You could try to use

How to determine the size (in bytes) of a file downloading using NSURLConnection?

人走茶凉 提交于 2019-12-05 13:30:07
I need to know the size of the file I am downloading (in bytes) into my app using NSURLConnection (GET). Here is my bytes recieved code below if it helps. What I need to know is how to get the filesize in bytes so that I can use it to show a UIProgressView. - (void)connection:(NSURLConnection *)theConnection didReceiveData:(NSData *)data // A delegate method called by the NSURLConnection as data arrives. We just // write the data to the file. { #pragma unused(theConnection) NSInteger dataLength; const uint8_t * dataBytes; NSInteger bytesWritten; NSInteger bytesWrittenSoFar; assert

NSURLSession delegate methods not called

浪尽此生 提交于 2019-12-05 13:23:51
I have created a very simple app to download a text file from my web server. I have this working perfectly with NSURLConnection, but am trying to migrate over to NSURLSession instead. The issue I am having is that none of the delegate methods are being called. My server is password protected so I need to use the basic http authentication to access the file, but when the didReceiveChallenge method is never called. The line of code [getFileTask resume] seems to have no effect on anything. My setup is as follows: @interface ViewController : UIViewController <NSURLSessionDelegate,