nsurlconnection

Asynchronous POST to server

眉间皱痕 提交于 2019-12-22 00:23:48
问题 The goal is to do a simple username/password authentication by querying a database. Until the connection is working decently my php destination file simply has following code: echo "Posted: " . $_POST['email']; The code to do this synchronously is this: NSString *post = [[NSString alloc] initWithFormat:@"email=%@&password=%@", self.email.text, ..]; // .. simplified keychainItem NSData *postEncoded = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:NO]; NSString *postLength =

How to make webservice pass errors through NSURLConnection's connection:didFailWithError:?

坚强是说给别人听的谎言 提交于 2019-12-21 19:34:53
问题 What does a web service need to do to cause NSURLConnection's delegate to receive the connection:didFailWithError: message? For example: iOS app passes a token to the web service, web service looks up the token, and then the web service needs to respond with an error saying "invalid token" or something of the like. Currently, the data is received, and in " connectionDidFinishLoading :" is parsed for error messages. This means I'm error checking in two places, which I am trying to avoid. I

NSURLConnection getting JSON File

ぐ巨炮叔叔 提交于 2019-12-21 17:51:37
问题 My iOS app is getting the code inside (ex. 101), and by that code it reads JSON file (ex. 101.json) on server and read the data inside. Everything is working good, but how to do that if there's no file (for that code) on server (now it's just showing no data if file not found) and if there's no internet connection just to get data from JSON file inside the app? Here's my code: NSString *baseURLStr = @"http://myserverurl/"; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL

How to detect if NSURLConnection's sendSynchronousRequest:returningResponse:error: ended up being timed out or other error

与世无争的帅哥 提交于 2019-12-21 14:59:12
问题 I use NSURLConnection's sendSynchronousRequest:returningResponse:error: method (in a separate NSOperation thread) to connect to external server to retreive data. How do I know if the operation ended timed out, or some other network error? 回答1: If there was an error, the error parameter will be non-nil when sendSynchronousRequest:returningResponse:error: returns. You can retrieve the error code by checking the value returned by [NSError code] . The error code for time out is NSURLErrorTimedOut

How to use HTTPS with NSURLConnection?

馋奶兔 提交于 2019-12-21 06:40:11
问题 I'm interested in HTTPS with NSURLConnection . Is it possible to send a request, respond to a challenge and load the secure URL? Is there anything else that can be done with NSURLConnection via HTTPS? 回答1: NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://monsite/mapage.php"] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0]; [request setHTTPMethod:@"POST"]; [request setHTTPBody:[[NSString stringWithFormat:@"score=222"]

NSURLConnection does not use the default credential

ぐ巨炮叔叔 提交于 2019-12-21 05:16:10
问题 I'm trying to connect to http://cmis.demo.nuxeo.org/nuxeo/atom/cmis/ with NSURLConnection . This demo web service is documented to require authentication (login: Administrator / password: Administrator). Edit : This web service now sends an authentication challenge, it was not at the time the question was asked. This web service does not send an authentication challenge, so I can't use the connection:didReceiveAuthenticationChallenge: delegate method. Instead I set a default NSURLCredential

XTubeManager crash in background?

↘锁芯ラ 提交于 2019-12-21 04:18:26
问题 I am experiencing a large amount of crashes in the XTubeManager (seems to be CFNetwork internal). Unfortunately the console logs are not available, only the call stack (see below). Questions: I could imagine that my app crashes in the background, therefore no console logs are written, do you think this is a possibility? Do I have to handle backgroundTask expiration differently, e.g. by cancelling all my NSURLRequests ? (see code below) Background I am regularly waking up in the background (or

NSURLConnection with blocks

陌路散爱 提交于 2019-12-21 04:15:14
问题 I'm using [NSURLConnection connectionWithRequest:req delegate:self]; and then I use -(BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace; -(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge; -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error; -(void)connection:(NSURLConnection *)connection didReceiveResponse:

Unable to get destinationURL data in connectionDidFinishDownloading for ios5

穿精又带淫゛_ 提交于 2019-12-21 03:54:20
问题 I'm trying to get a list of assests urls to download. I'm using NSURLConnection in order to get a JSON file that have this list of urls. in - (void)connection:(NSURLConnection *)connection didWriteData:(long long)bytesWritten totalBytesWritten:(long long)totalBytesWritten I'm getting 122239 as total bytes written. when - (void)connectionDidFinishDownloading:(NSURLConnection *)connection destinationURL:(NSURL *)destinationURL is called I'm trying to read the url data in order to extract the

Populating NSImage with data from an asynchronous NSURLConnection

∥☆過路亽.° 提交于 2019-12-20 14:42:09
问题 I have hit the proverbial wall trying to figure out how to populate an NSImage with data returned from an asynchronous NSURLConnection in my desktop app (NOT an iPhone application!!). Here is the situation. I have a table that is using custom cells. In each custom cell is an NSImage which is being pulled from a web server. In order to populate the image I can do a synchronous request easily: myThumbnail = [[NSImage alloc] initWithContentsOfFile:myFilePath]; The problem with this is that the