nsurlconnection

Delay when updating view in the completionHandler of an async HTTP request

老子叫甜甜 提交于 2019-11-30 23:20:00
In my app when the user presses a button I start a HTTP asynchronous request (using [NSURLConnection sendAsynchronousRequest...] ) and change the text of UILabel in the completionHandler block. This change, however, does not take place when the request is concluded and instead happens around 2-3 seconds later. Below is a code snippet that results in this behavior. - (IBAction)requestStuff:(id)sender { NSURL *url = [NSURL URLWithString:@"http://stackoverflow.com/"]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; NSOperationQueue *queue = [[[NSOperationQueue alloc] init] autorelease]

Error: __tcp_connection_write_eof_block_invoke Write close callback received error - iOS 10

旧街凉风 提交于 2019-11-30 21:35:01
While sending XML base API Request to ONVIF Camera. It worked fine on ios 9 device, but giving '500 Internal Error' on iOS 10. XCode 8 Console prints below error messages: 2016-09-30 12:39:51.295419 VCPlugin[278:10183] [] nw_socket_get_input_frames recvmsg(fd 12, 1024 bytes): [54] Connection reset by peer 2016-09-30 12:39:51.301221 VCPlugin[278:10228] [] nw_socket_write_close shutdown(12, SHUT_WR): [57] Socket is not connected 2016-09-30 12:39:51.301307 VCPlugin[278:10228] [] nw_endpoint_flow_service_writes [3 10.107.2.153:80 ready socket-flow (satisfied)] Write request has 0 frame count, 0

Can iOS devices send PUT requests to Rails apps?

断了今生、忘了曾经 提交于 2019-11-30 19:41:56
We've tried numerous times sending update PUT requests to our Rails server and we keep receiving a 404 "The page you were looking for does not exist" Our update method is very simple (practically generic rails). def update @user = User.find(params[:id]) respond_to do |format| if @user.update_attributes(params[:user]) format.html { redirect_to @user, notice: 'User was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @user.errors, status: :unprocessable_entity } end end end When I run CURL from the command line to

iPhone NSData/NSUrl with cookie

∥☆過路亽.° 提交于 2019-11-30 19:25:35
问题 I'm trying to play/stream a mp3 hosted on a website. The site requires a cookie header to be set, but I'm having trouble setting that or getting the container to do that for me. NSURL *sampleUrl = [NSURL URLWithString:@"http://domain/files/sample.mp3"]; NSData *sampleAudio = [NSData dataWithContentsOfURL:sampleUrl]; Up until this point, I've been using jQuery to do/manage XMLHTTPRequests, but I've had to call into native code to stream the audio. It doesn't look like the cookie is getting

When to call release on NSURLConnection delegate?

我们两清 提交于 2019-11-30 17:44:48
问题 When passing a delegate to the a NSUrlConnection object like so: [[NSURLConnection alloc] initWithRequest:request delegate:handler]; when should you call release on the delegate? Should it be in connectionDidFinishLoading ? If so, I keep getting exec_bad_access . I'm seeing that my delegates are leaking through instruments. Thanks 回答1: Taken from my blog post here: http://i.ndigo.com.br/2012/01/releasing-nsurlconnection-and-its-delegate/ You will have to pay extra attention to the delegate

Read NSURLresponse

落花浮王杯 提交于 2019-11-30 17:43:51
i am sending an object to this adrees : https://sandbox.itunes.apple.com/verifyReceipt with NSUrlconnection and i am trying to read it with this delegate method : - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response like this : NSlog(@"%@",response); i am getting this code : <NSHTTPURLResponse: 0x7d2c6c0> i need to get a string somehow. how can i read it? I wrote this answer to another question, but I think it will help you. Have a look in particular at the methods -(void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data and -(void

Read NSURLresponse

ぃ、小莉子 提交于 2019-11-30 16:41:15
问题 i am sending an object to this adrees : https://sandbox.itunes.apple.com/verifyReceipt with NSUrlconnection and i am trying to read it with this delegate method : - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response like this : NSlog(@"%@",response); i am getting this code : <NSHTTPURLResponse: 0x7d2c6c0> i need to get a string somehow. how can i read it? 回答1: I wrote this answer to another question, but I think it will help you. Have a look in

Perform POST request in iOS Swift

本秂侑毒 提交于 2019-11-30 16:10:09
I am trying perform a POST request and the request does not go through. I have looked through Perform POST request in Swift already but it does not contain what I'm looking for. func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool { var request = NSMutableURLRequest(URL: NSURL(string: "https://us1.lacunaexpanse.com")) println("request url https://us1.lacunaexpanse.com") var session = NSURLSession.sharedSession() request.HTTPMethod = "POST" let apikey = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" println("apikey",apikey) let username =

iOS4 Implementation of -[NSURLConnection sendAsynchronousRequest:queue:completionHandler:]?

被刻印的时光 ゝ 提交于 2019-11-30 15:46:40
How can I implement -[NSURLConnection sendAsynchronousRequest:queue:completionHandler:] for iOS < 5? #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0 #import <objc/runtime.h> #import "NSURLConnection+iOS4.h" // Dynamically add -[NSURLConnection sendAsynchronousRequest:queue:completionHandler:]. void *sendAsynchronousRequest4(id self, SEL _cmd, NSURLRequest *request, NSOperationQueue *queue, void (^handler)(NSURLResponse*, NSData*, NSError*)); void *sendAsynchronousRequest4(id self, SEL _cmd, NSURLRequest *request, NSOperationQueue *queue, void (^handler)(NSURLResponse*, NSData*, NSError*))

iPhone SDK: URL request not timing out

こ雲淡風輕ζ 提交于 2019-11-30 15:45:34
I am having a problem with a network request that should timeout, but the method is not called. The request is as follows: #define kCONNECT_TIMEOUT 20.0 request = [NSMutableURLRequest requestWithURL: aUrl]; [request setHTTPMethod: @"POST"]; postData = [jsonData dataUsingEncoding:NSASCIIStringEncoding]; [request setHTTPBody:postData]; [request setValue:@"text/xml" forHTTPHeaderField:@"Accept"]; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [request setCachePolicy:NSURLCacheStorageAllowed]; [request setTimeoutInterval:kCONNECT_TIMEOUT]; self.connection =