nsurlconnection

HttpBasicAuthentication in IPhone

蹲街弑〆低调 提交于 2019-11-30 10:58:01
In my iPhone app, I am trying to display an image on iphone from my server, which needs authorization. I am trying to use NSURLConnection to get the image, but it is not asking me for the user credentials. i.e it is not at all going to didReceiveAuthenticationChallenge method. Can anyone help me with this issue? You can compute the necessary Authorization header yourself and manually apply it to the outgoing NSURLRequest before creating the NSURLConnection, as in: NSMutableURLRequest *someURLReq = ... NSString *auth = ... [someURLReq setValue:auth forHTTPHeaderField:@"Authorization"]; The

NSURLSession + server with self signed cert

谁说我不能喝 提交于 2019-11-30 10:46:42
问题 I have an app that is production along with a development server that has a self signed certificate. I am attempting to test NSURLSession and background downloading but can't seem to get past - (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler When I use NSURLConnection I am able to bypass it using: - (BOOL)connection

NSURLSession delegate vs. completionHandler

十年热恋 提交于 2019-11-30 10:39:41
问题 I've always used completion handlers. With NSURLConnection and now with NSURLSession . It's led to my code being really untidy, especially I have request within request within request. I wanted to try using delegates in NSURLSession to implement something I've done untidily with NSURLConnection . So I created a NSURLSession , and created a dataTask : NSURLSessionDataTask *dataTask = [overallSession dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)

Asynchronous NSURLConnection Throws EXC_BAD_ACCESS

感情迁移 提交于 2019-11-30 09:43:59
I'm not really sure why my code is throwing a EXC_BAD_ACCESS, I have followed the guidelines in Apple's documentation: -(void)getMessages:(NSString*)stream{ NSString* myURL = [NSString stringWithFormat:@"http://www.someurl.com"]; NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:myURL]]; NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if (theConnection) { receivedData = [[NSMutableData data] retain]; } else { NSLog(@"Connection Failed!"); } } And my delegate methods #pragma mark NSURLConnection Delegate Methods -

How can we handle multiple NSURLConnection in iPhone Xcode?

只愿长相守 提交于 2019-11-30 07:35:59
I am developing one small app in which i have multiple NSURLConnection.I have created that NSURL Connection but i don't know how to handle it.My code is like below. -(void) loadTrafficAndEvent { int a=10; //Get the map view bounds for fetch the travel time markers from web service MKCoordinateRegion region = mapView.region; float print = region.center.latitude; // NSLog(@"region.center=%g",print); CGPoint firstcorner = CGPointMake(self.mapView.bounds.origin.x , mapView.bounds.origin.y); CGPoint secondcorner = CGPointMake((self.mapView.bounds.origin.x+mapView.bounds.size.width) , mapView.bounds

NSURLConnection on iOS doesn't try to cache objects larger than 50KB

孤人 提交于 2019-11-30 07:30:17
问题 Despite Apple's documentation indicating otherwise, NSURLCache on iOS doesn't do any disk (flash) caching at all. You can subclass NSURLCache to change the behaviour of the fetch and store operations to use the disk (like SDURLCache does), but due to the following severe limitations of how the cache is used and implemented, this doesn't work as well as you'd expect: NSURLConnection doesn't even call storeCachedResponse:forRequest: for files over about 50KB (>= 52428 bytes, to be exact). This

_kCFStreamErrorCodeKey=-2102 only with wifi of some ISPs

帅比萌擦擦* 提交于 2019-11-30 07:25:44
问题 I use below code to send a file to the server: NSString *urlString = [NSString stringWithFormat:@"%@%@",[LIUtility sharedUtility].uploadConnectionURL,BR_SERVER_UPLOAD_ADDRESS_FILE]; self.request =[[NSMutableURLRequest alloc] init]; [self.request setURL:[NSURL URLWithString:urlString]]; [self.request setHTTPMethod:@"POST"]; PKMultipartInputStream *body = [[PKMultipartInputStream alloc] init]; NSString *requestString =[self getRequestStringForRange:range andExtension:fileName]; NSData

NSURLConnection delegation and threading - iPhone

青春壹個敷衍的年華 提交于 2019-11-30 07:16:24
问题 I have a class that updates two .plist files in the app documents directory via an NSURLConnection. The class acts as its own delegate for NSURLConnection. It works properly when I ask for a single file, but fails when I try to update two files. Does it look like I should start a new thread for each of the getNewDatabase messages? - (void)getAllNewDatabases { [self performSelectorOnMainThread:@selector(getNewDatabase:) withObject:@"file1" waitUntilDone:YES]; [self performSelectorOnMainThread:

Request with NSURLRequest

倾然丶 夕夏残阳落幕 提交于 2019-11-30 07:06:14
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 loading the view, typically from a nib. NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL

Determining Trust With NSURLConnection and NSURLProtectionSpace

僤鯓⒐⒋嵵緔 提交于 2019-11-30 05:57:10
问题 I would like to ask a followup question to a previously posed question. I've got the code to create an NSURLRequest/Connection, run it and have the callback methods for authentication get called. Here's the specific code: - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust] || [protectionSpace.authenticationMethod