nsurlconnection

NSURLConnection Download multiple images

浪尽此生 提交于 2019-12-01 08:35:03
问题 I am trying to download multiple images from a URL stored in an XML feed. Getting the image urls from the XML is working correctly. However, the NSURLConnection is creating empty files, but the data is received as noted in NSLog. In connectionDidFinishLoading:(NSURLConnection *)connection , the data and correct bytes are received, the problem is how do I make the receivedData write to the correct file. Semi-working code: -(void)parsingComplete:(XMLDataSource*)theParser { /* iterate through

Async NSURLConnection, Concurrent NSOperation, when to use NSRunLoop?

試著忘記壹切 提交于 2019-12-01 07:39:47
I'm trying to run NSURLConnection async in a secondary thread (target is iOS4), for this I have created a concurrent NSOperation, I think I'm almost there, but am not clear on the following: 1) in iOS4 NSOperationQueue addOperation starts the operation in a new thread, because of the use of GCD, based on Technical Q&A QA1712 , however, my tests (simulator and iPad) show that start() is always called on the main thread, any idea, do I need a check here: if on main thread then spawn a new one? 2) if start was actually called on a secondary thread by addOperation(), then I could start my async

Objective-C SSL Synchronous Connection

倾然丶 夕夏残阳落幕 提交于 2019-12-01 06:35:02
I'm a little new to objective-C but have run across a problem that I can't solve, mostly because I'm not sure I am implementing the solution correctly. I am trying to connect using a Synchronous Connection to a https site with a self-signed certificate. I am getting the Error Domain=NSURLErrorDomain Code=-1202 "untrusted server certificate" Error that I have seen some solutions to on this forum. The solution i found was to add: - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { return [protectionSpace

Objective-C SSL Synchronous Connection

霸气de小男生 提交于 2019-12-01 05:33:55
问题 I'm a little new to objective-C but have run across a problem that I can't solve, mostly because I'm not sure I am implementing the solution correctly. I am trying to connect using a Synchronous Connection to a https site with a self-signed certificate. I am getting the Error Domain=NSURLErrorDomain Code=-1202 "untrusted server certificate" Error that I have seen some solutions to on this forum. The solution i found was to add: - (BOOL)connection:(NSURLConnection *)connection

Async NSURLConnection, Concurrent NSOperation, when to use NSRunLoop?

ぃ、小莉子 提交于 2019-12-01 05:24:18
问题 I'm trying to run NSURLConnection async in a secondary thread (target is iOS4), for this I have created a concurrent NSOperation, I think I'm almost there, but am not clear on the following: 1) in iOS4 NSOperationQueue addOperation starts the operation in a new thread, because of the use of GCD, based on Technical Q&A QA1712, however, my tests (simulator and iPad) show that start() is always called on the main thread, any idea, do I need a check here: if on main thread then spawn a new one? 2

Best way to handle multiple NSURL connections

别等时光非礼了梦想. 提交于 2019-12-01 04:48:12
I am trying to create an xls sheet programmatically. To fill the sheet, I am making the multiple NSURLConnection around 100. Right now, my approach is : Make a connection and store the data into an array . This array has 100 objects. Now take the first object and call the connection . Store the data. And make the second connection with 2nd object in the array. This continues till the last object in the array. It takes on average 14 seconds to finish the 100 connections. Is there any way to implement the NSURLConnection to get the response in a faster way? Till yesterday I followed the basic

Stop an NSRunLoop

时光怂恿深爱的人放手 提交于 2019-12-01 04:02:42
I have a connection in a thread, so I add it to the run loop to get all data: [[NSRunLoop currentRunLoop] run]; [connection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; But I can't find any way to stop it - (void)connectionDidFinishLoading:(NSURLConnection *)connection{ if([NSRunLoop currentRunLoop]){ [[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget:self]; } [connection cancel]; } How can I stop this loop? You can stop the runloop by Core Fundation API : CFRunLoopStop(CFRunLoopGetCurrent()); 来源: https://stackoverflow.com/questions/16211915/stop-an

Maximum number of concurrent NSURLConnections to the same host?

你离开我真会死。 提交于 2019-12-01 03:59:33
I'm running in to an issue in an OS X app that creates multiple, persistent connections to the same host using NSURLConnection. I create a separate connection for different rooms, and it stays connected the entire time the room is open to consume a streaming API. When opening many rooms, it stops working correctly. I created a separate sample app that creates 10 connections, and it seems to only allow 6 connections to work, and the others are queued. Does anyone know if there is a way to override this limit? I can't find it documented anywhere. The only workaround I've found is it seems to be

Notification when Internet became available on iOS

爷,独闯天下 提交于 2019-12-01 03:49:59
问题 Is it possible to receive a notification or something inside my app when the internet BECOMES available. I'm aware of reachability and all kinds of stuff. But what i want is to start some pending NSUrlConnections when internet becomes available on the device. Is there a easy way to do this, because I don't want to use a looping thread that checks constantly for reachability. Any suggestions? 回答1: Ok, here is very nice post about Reachability: http://www.mikeash.com/pyblog/friday-qa-2013-06-14

ASIHTTPRequest vs NSURLConnection

跟風遠走 提交于 2019-12-01 00:40:13
问题 Just wondering which is faster in terms of performance and usability? Or if there's anything better out there? 回答1: There's some performance information relating to an old version here: http://allseeing-i.com/ASIHTTPRequest-1.5 It's pretty comparable. I'm not sure if there are any figures for more recent versions. Note that the most recent ASIHTTPRequest has built in support for caching (which NSURLConnection doesn't) - if you enable that and it's applicable for your use it gets you a major