nsurlconnection

Uploading large images using Base64 and JSON

一世执手 提交于 2020-01-01 05:15:16
问题 I am using this function to upload an image to a server using JSON . In order to do so, I first convert the image to NSData and then to NSString using Base64 . The method works fine when the image is not very large but when I try to upload a 2Mb image, it crashes. The problem is that the server doesn't receive my image even though the didReceiveResponse method is called as well as the didReceiveData which returns (null) . At first I thought it was a time out issue but even setting it to 1000

POST with NSURLConnection - NO JSON

左心房为你撑大大i 提交于 2020-01-01 00:45:35
问题 I am trying to write an iPhone app in Objective-C. I need to POST data using NSURLConnection. Every example I can find deals with JSON; I do not need to use JSON. All I need to do is POST the data and get a simple 1 or 0 (succeed or fail) from a PHP script. Nothing more. I came across this code but I am not sure how to use it or modify it to not use JSON: - (void)performRequest { NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://someplace

Convert NSURLConnection to NSURLSessionUploadTask example

孤人 提交于 2019-12-31 03:07:25
问题 Hi everyone and thanks in advance for any help providing in understanding in how to convert some NSURLConnection code into the newer NSURLSession. What I am trying to do is to make a POST request to a server, and send a photo base 64 encoded for the key "photo". Below I have an working example written in NSURLConnection and I will like to convert it into NSURLSession. As I read on the apple documentation from what I understood I should use a Data tasks because in my case it is an image and if

NSURLConnection timing out on iOS8

你离开我真会死。 提交于 2019-12-30 18:55:26
问题 I have been working on an application involving client-server communication. Everything was working fine until iOS 7.1. Now that Xcode 6 GM Seed in launched, I tried to build and run the project on iOS8 simulator. However, all NSURLConnections seem to time out now. I can not get any response from the server. This works on iOS 7 simulator and Xcode 6. I tried using the NSURLSession hoping that would resolve the issue. But it hasnt. Any help will be highly appreciated!! If anyone else has faced

Error: __tcp_connection_write_eof_block_invoke Write close callback received error - iOS 10

╄→尐↘猪︶ㄣ 提交于 2019-12-30 06:42:18
问题 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

Request with NSURLRequest

我与影子孤独终老i 提交于 2019-12-30 02:13:25
问题 I'm trying do to an app which uses a database (actually in my localhost), I tried with ASIHTTPRequest but having so much troubles with iOS 5 (I learnt how to use ASIHTTPRequest form there : http://www.raywenderlich.com/2965/how-to-write-an-ios-app-that-uses-a-web-service Now i'm trying with the API provided by Apple : NSURLRequest / NSURLConnection etc,... I read the Apple online guide and make this first code : - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after

Does NSURLConnection take advantage of NSURLCache?

天涯浪子 提交于 2019-12-30 00:35:53
问题 I'm trying to figure out how to use the URL loading framework to load URLs taking advantage of caching. I am using NSURLConnections and feeding them NSURLRequests. I have even set the cachePolicy on those requests to NSURLRequestReturnCacheDataElseLoad. The first time I load a request, it does automatically get put in the cache ( [NSURLCache sharedCache] has it). But the next time I load the same request, the NSURLConnection seems to ignore what's in the cache and reload the data. Am I

iphone: secure restfull server "The certificate for this server is invalid

北战南征 提交于 2019-12-29 05:30:07
问题 I am trying to consume secure restful service which gives error Error = Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “xxx.xxx.xxx.xxx” which could put your confidential information at risk." working on xCode 4.2, where is the mistake or any step missing. using following code RegisterUser.f @interface RegisterUser : UIViewController<UITextFieldDelegate, UIScrollViewDelegate,

Parsing JSON response .

我是研究僧i 提交于 2019-12-29 02:11:06
问题 - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { response=[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];} Here, I get the response in the "response value" --> [{"response":true,"danger":false}] The thing is: How can I rescue the "danger"(true/false) into a new variable to use it in other methods? I need to know if "danger" is true or false becouse if its true, i have to show an alert. I would really appreciate someone help, as I am stuck in

NSURLConnection is run many times

橙三吉。 提交于 2019-12-28 12:43:05
问题 I connect asynchronously with server each 5 seconds. The URL is the same, but POST-body is changed each time. Now I create NSURL, NSURLRequest and NSURLConnection from the scratch each time. I think it'd be more effective to set connection once and just use that one further. I am a newbie and not sure if that possible. There is no mutable NSURLConnection, but may it's need to create NSURLConnection like: NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: url];