nsurlconnection

NSURLConnection does not call complete across multiple Views

风格不统一 提交于 2019-12-12 04:22:21
问题 Earlier today I asked the following question: iOS block being stoped when view pushed The operation I mentioned (OP1) is actually a "http get" to my server, using NSURLConnection. After even more investigation I discovered that the block doesn't actually "die". What really happens is that the request is actually SENT (the server side logs it), even after the view is pushed (verified via [NSThread sleep:10]). The server responds but then NOTHING happens on the app side if the view2 has been

Handle 401 status code with sendAsynchronousRequest:request API in iOS

◇◆丶佛笑我妖孽 提交于 2019-12-12 03:14:44
问题 I am using this way API to login in my app. NSString *url = [NSString stringWithFormat:@"%@//login",xyz]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]]; NSError *error; NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&error]; if (!jsonData) { NSLog(@"Error creating JSON object: %@", [error localizedDescription]); } [request setValue:@"application/json;charset=utf-8" forHTTPHeaderField:@

iOS download file from a URL that will redirect to the file

不想你离开。 提交于 2019-12-12 02:55:57
问题 I've been trying for 2 days and cant figure this out. Basically I have a URL and I try to download the file that associate with it using ASIHTTPRequest, but the URL I have is not the link of the file itself, but that URL will redirect to the link of the actual file. I try to give that link to ASIHTTPRequest for download, but it didn't. SO I think I have to somehow get the redirected url and feed that to ASIHTTPRequest to download the file. How can I do this? Thanks all for reading :) 回答1: You

iOS Mediaplayer and URL redirection

萝らか妹 提交于 2019-12-12 02:34:40
问题 I'm trying to implement a MPMedia player to play internet files. So far I have managed to open the media player with links to videos hosted by me. The problem starts when I try to load an url that doesn't directly map to a file but instead gets redirected to the file. The initial url looks like this: h*tp://www.example.com/ numbers/numbers/numbers and when I put it in my browser it is automatically changed for something like this: h*tp://www.example.com/ numbers .mp4?to= numbers When I use

App loads images over wifi, but not 3g

心已入冬 提交于 2019-12-12 02:34:16
问题 I am having a really weird issue. My app runs great on wifi, all of my images load from the net. If i run the app for the very first time on 3G, images wont load. If I switch to wifi, then switch back to 3G, images will load (new images load as well as they change). I have no idea how to diagnose. 回答1: This might be an issue with your service provider (cell-phone tower). On 3g, can you load a website (say, apple.com) and the images show? 回答2: Some suggestions Show some image loading code. Do

Wait for an NSURLConnection

旧城冷巷雨未停 提交于 2019-12-12 01:59:02
问题 I have code that sends away a HTTP POST connection. I want the method to wait until I get a response from the server for it to continue. The reason I am doing it this way is because I am integrating new code (asynchronous post vs the old synchronous post) into our application and I am looking for minimal change throughout the application. The old method was as follows: -(NSData*) postData: (NSString*) strData; The application would call it and send it a strData object and it would lock the

Establish synchronous connection with the sever in swift

吃可爱长大的小学妹 提交于 2019-12-12 01:54:03
问题 I have the following function to establish the connection synchronously with the sever on a particular IP and port, send a JSON request to sever and return the server's response to the calling function. func connserv(jsonString:NSDictionary){ var abc: NSDictionary? // This is the action performed when clicked on the Connect button on the connectivity screen println("------------------Function connserv") let prefs = NSUserDefaults.standardUserDefaults() var IP: AnyObject = prefs.objectForKey(

Upload files (images, pdf) with parameters to the server

半腔热情 提交于 2019-12-12 01:48:22
问题 I would like to upload 1pdf file and array of images. I can upload 1pdf and 2jpg files, if jpg files more than two I get message: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (No value.) UserInfo=0x174268000 {NSDebugDescription=No value.} Why is this happening? Also I tested server with POSTMAN and it work well. NSURL *URL = [NSURL URLWithString:constFileUploadURL]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];

Async Images Download in a Table

自古美人都是妖i 提交于 2019-12-12 01:20:01
问题 I have a table view and I'd like to download an icon image (100x75) to each row asynchronously. I've followed many tutorials so far but I can't seem to figure it out. How should I do it? Does anyone recommend just doing it using the standard NSURLConnection API or should I use one of those classes/libraries that are available online to do so? If so, what do you recommend? Of course, I need it to be fast, efficient and does not leak. I also don't want the downloading to affect the scrolling.

strange multiple files download - NSURLConnection

[亡魂溺海] 提交于 2019-12-11 21:31:46
问题 I encounter a problem by following your comment. I would like to download different file at same time with different delegate: .h: NSMutableData *fileData; .m: NSString *imgfile = [NSString stringWithFormat:@"http://xxxx/01.jpg"]; NSURL *fileURL1 = [NSURL URLWithString:imgfile]; NSString *audiofile = [NSString stringWithFormat:@"http://xxxx/01.mp3"]; NSURL *fileURL2 = [NSURL URLWithString:audiofile]; NSURLRequest *request1 = [NSURLRequest requestWithURL:fileURL1 cachePolicy