nsurlconnection

NSURLConnection inherent memory leak?

谁说胖子不能爱 提交于 2019-12-11 02:37:16
问题 In the example in the Xcode Documentation : URL Loading System Programming Guide : Using NSURLConnection, they alloc an NSURLConnection ( theConnection ) and then release it in the callbacks: -connection:didFailWithError: & -connectionDidFinishLoading: . But, won't theConnection leak (i.e. never get released) if the delegate is released before either of the callback methods get called? 回答1: No, theConnection won't leak because, as the Xcode Documentation for -[NSURLConnection initWithRequest

NSURLConnection retry on 401 status

丶灬走出姿态 提交于 2019-12-11 02:33:45
问题 I'm communicating with a server that validates a password and returns a 401 error on invalid password, together with a json body specifying the number of failed attempts. That number is incremented by the server on each failed validation. The problem I'm facing is that when NSURLConnection gets a 401 response, it kicks an authentication mechanism that involves these delegate methods: connection:canAuthenticateAgainstProtectionSpace: connection:didReceiveAuthenticationChallenge: If I return NO

iPhone - NTLM, Basic and other authorizations using async NSURLConnection

社会主义新天地 提交于 2019-12-11 01:58:27
问题 Here's an issue: I need to implement both HTTP basic authorization and MS NTLM authorization. I use asynchronous NSURLConnection so I receive -(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge callback. The full code of this method looks like that: -(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { NSString* authMethod = [[challenge

NSURLConnection failure - 1003

喜欢而已 提交于 2019-12-10 23:19:07
问题 I try to retrive data from certain url with command: -(NSMutableData *) callUrl: (NSString *)url withData:(NSMutableDictionary *)data delegate:(id) delegate { NSURL *executeUrl = [NSURL URLWithString:<string>]; NSURLRequest *request = [NSURLRequest requestWithURL: executeUrl cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60]; NSMutableData *receivedData = nil; NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:delegate]; if

do not Backup flag for iOS 5.1?

ⅰ亾dé卋堺 提交于 2019-12-10 23:05:02
问题 my first music downloading app get rejected due to some issues in data storage guidelines. i tried to save my mp3 file in NSDocumentDirectory. i need to resubmit my app by adding flag "Do not backup". here is my code, NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectoryPath = [[paths objectAtIndex:0]stringByAppendingPathComponent:@"Music.mp3"]; [receivedData writeToFile:documentsDirectoryPath atomically:YES]; [self

Calling NSURLConnection inside dispatch_async and reading didReceiveResponse in mainRunLoop in iPhone development

元气小坏坏 提交于 2019-12-10 20:57:26
问题 What I am trying to do is getting response for following method - (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { } after calling this NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self]; [conn scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; [conn start]; inside a dispatch_async(); But the connection method is not calling. But when I run the NSURLConnection code outside the dispatch

NSURLConnection throws after updating to Swift 2.0

て烟熏妆下的殇ゞ 提交于 2019-12-10 20:17:00
问题 Before the Swift 2.0 Update this code worked perfectly to download my JSON File from the Server with a PHP Script: let url = NSURL(string: webAdress) let cachePolicy = NSURLRequestCachePolicy.ReloadIgnoringLocalAndRemoteCacheData var request = NSMutableURLRequest(URL: url!, cachePolicy: cachePolicy, timeoutInterval: 5.0) var response: NSURLResponse? = nil var error: NSError? = nil let reply = NSURLConnection.sendSynchronousRequest(request, returningResponse:&response, error:&error) After the

NSURLConnection (as part of AFNetworking) doesn't call NSURLConnectionDataDelegate delegate

浪尽此生 提交于 2019-12-10 19:06:33
问题 The Issue I am using AFNetworking, which generates an NSURLConnection object, to upload a photo. The NSURLConnection is not making any calls to the - (void)connection:(NSURLConnection __unused *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite method. (It's part of the NSURLConnectionDataDelegate protocol, defined in NSURLConnection.h) The request is an HTTP POST request with a

How to fix NSURLErrorDomain error -1012 in authentication?

谁都会走 提交于 2019-12-10 18:40:38
问题 I'm dealing the authenticate issue with Tumblr account using [NSURLConnection sendAsynchronousRequest:queue:completionHandler:] to send the authenticate request, but here I meet a tough problem: Whenever I send the request at the first time , everything goes perfectly, but when the first authentication is done and then resend the request second time , there comes "NSURLErrorDomain error -1012". The authenticate page is loaded in a webview so that the authentication should be done in my app

Asynchronous NSURLConnection Scheme Tutorial

廉价感情. 提交于 2019-12-10 18:08:01
问题 I am looking for a good tutorial on using the NSURLConnection Asynchronous request. I have been looking around in stackoverflow and Google but could not find one. This can be a duplicate of zillions of questions like this here. But please direct me to the correct tutorial, I have used ASIHTTPRequest before, but I have not used the Apple provided library before. 回答1: I would provide you with one written myself, however I would HIGHLY recommend using AFNetworking, it's a wrapper above the