nsurlrequest

NSURLRequest with url containing special characters

核能气质少年 提交于 2020-01-16 05:35:29
问题 I'm having the same problem as: NSURL with special characters But tried their solution. Can't get my NSURLRequest to work with åöä characters. If the variable "string" contains åöä the request return null. Also tried with NSISOLatin1StringEncoding. NSString *encodedString = [string stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *urlString = [NSString stringWithFormat: @"http://suggestqueries.google.com/complete/search?output=firefox&q=%@", encodedString]; NSURL *url

Async data connections iOS

情到浓时终转凉″ 提交于 2020-01-15 07:52:32
问题 I've written a synchronisation class for the app I'm currently working on. Because of the large amount of data it first gets a data count and then batches up the downloads in an NSOperationQueue . This all works fine and I've got the sync algorithm working quickly. The way it works is as follows... - (void)synchroniseWithCompletionHandler://block for completion handler errorHandler://block for error handler { [self.queue addOperationWithBlock ^{ //Create an NSURLRequest for the first batch /

how to know when NSURLRequest finish loading

送分小仙女□ 提交于 2020-01-14 16:53:17
问题 Im implementing an app that shows some Twitter data, when is working on wifi is ok, but on 3g crashes, I have come to the conclusion that is because the NSURLRequest that fetchs the data that populates the table takes longer to load so the table ends up calling an object for key, when the keys havent even loaded, So the question is, - how can I know when the NSURLRequest finished loading? [I checked the Class Reference but didnt see it??] Thanks a lot! 回答1: The delegate methods are invoked on

how to know when NSURLRequest finish loading

主宰稳场 提交于 2020-01-14 16:51:58
问题 Im implementing an app that shows some Twitter data, when is working on wifi is ok, but on 3g crashes, I have come to the conclusion that is because the NSURLRequest that fetchs the data that populates the table takes longer to load so the table ends up calling an object for key, when the keys havent even loaded, So the question is, - how can I know when the NSURLRequest finished loading? [I checked the Class Reference but didnt see it??] Thanks a lot! 回答1: The delegate methods are invoked on

How can I set the “User-Agent” header of a UIWebView in Swift

不羁岁月 提交于 2020-01-09 12:51:12
问题 I am using Xcode 6 for an iOS App with Swift. I have got a simple ViewController with an embedded UIWebView. You can find the code below. Now I want to change the User-Agent HTTP header. I tried to use the setValue method of NSURLRequest but it didn't work (see uncommented line). Does anyone know how to do that? import UIKit class WebViewController: UIViewController { @IBOutlet weak var webView: UIWebView! override func viewDidAppear(animated: Bool) { var url = NSURL(string: "https://www

Failing to POST NSData of PDF to server

旧城冷巷雨未停 提交于 2020-01-06 19:32:30
问题 I have an iPad application in which I need to send a server a PDF file, alongside two POST variables, a user ID and a job ID. I am using the code below to do this: NSData *pdfData = [NSData dataWithContentsOfFile:currentPDFFileName]; NSData *validPDF = [[NSString stringWithString:@"%PDF"] dataUsingEncoding: NSASCIIStringEncoding]; if (!(pdfData && [[pdfData subdataWithRange:NSMakeRange(0, 4)] isEqualToData:validPDF])) { NSLog (@"Not valid"); } NSLog (@"%@", currentPDFFileName); NSLog (@"%@",

Getting leak in leak in [NSURLConnection sendSynchronousRequest:theRequest returningResponse:nil error:nil]

こ雲淡風輕ζ 提交于 2020-01-01 07:26:08
问题 I am having a leak in returnData= [NSURLConnection sendSynchronousRequest:theRequest returningResponse:nil error:nil]; The below is the code i am using NSString* curl = @"https://Some Url?ticket="; curl = [curl stringByAppendingString:self.ticket]; curl = [curl stringByAppendingString:@"&apikey=hjgajgfjaghjf&XMLString="]; curl = [curl stringByAppendingString:stringB]; curl = [curl stringByReplacingOccurrencesOfString:@"\n" withString:@""]; NSURL *finalURL = [NSURL URLWithString:curl];

Monotouch + UIWebView = Random Crashes

本小妞迷上赌 提交于 2019-12-30 06:57:11
问题 I'm using the latest stable releases of Mono/Monotouch/MonoDevelop on a iOS 5.0 iPhone and iPad. I have a UIWebView that in the emulator never crashes however randomly on the actual devices it crashes on EXC_BAD_ACCESS. Based on everything I've read with UIWebViews that most likely occurs when the UIWebView gets disposed before it finishes loading. Here is the code I am using in my ViewDidLoad(): var urlAddress = BASE_URL + _page; var nsURL = new NSUrl(urlAddress); var nsURLRequest = new

NSURLRequest: How to handle a redirected post?

我的梦境 提交于 2019-12-30 03:10:29
问题 I have a tried and tested use of NSURLRequest (and accompaniments) implementation, that works great for GETs, and POSTs for a given URL. However, I want to now move the target of the URL without changing the URL used by the app, so I'm intending to use a webhop redirect via my DNS provider. This works fine for the GET requests, but the POSTs just hang... no connection response is received. The relevant iOS method for handling a redirect is, -(NSURLRequest *)connection:(NSURLConnection *

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