nsurlconnection

NSURLConnection leak?

孤街醉人 提交于 2019-11-28 18:28:17
i have set up a nsurl which grabs the data from http. when i run instrument, it says i have a leak NSFNetwork object. and how do i release theConnection in (void)ButtonClicked? or it will be release later on? - (void)ButtonClicked { NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:KmlUrl] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0f]; NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if (theConnection) { // receivedData is declared as a method instance elsewhere NSMutableData *receivedData =

NSURLConnection methods no more available in IOS5

自闭症网瘾萝莉.ら 提交于 2019-11-28 16:32:54
I was looking at the NSURLConnection class which could be used to establish a sync or async connection to an URL and then retrieve its data... a lot of changes have been made to this class with IOS 5 and I've seen they introduced some formal protocols related to authentication or download, but I don't see, for example, if the connection:didReceiveResponse: message (that was previously sent to the delegate and that it is no more available) is still available in some protocols.. How do you implement an async connection and retrieve, for example, HTTP headers as soon as the Response is received?

Delayed UIImageView Rendering in UITableView

白昼怎懂夜的黑 提交于 2019-11-28 15:32:36
Ok, I've got a UITableView with custom UITableViewCell s that each contain a UIImageView whose images are being downloaded asynchronously via an NSURLConnection . All pretty standard stuff... The issue is, when the table scrolls, the new images are downloaded in the background correctly but not RENDERED until the table stops moving. How do I get the table to render it's content even when it's moving? Thanks. -- UPDATE -- After a closer look, I'm finding that the NSURLConnection delegate methods aren't firing until the table stops scrolling. Not sure why. Any help would be great. The reason the

Parsing JSON response .

痴心易碎 提交于 2019-11-28 14:48:51
- (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 here. use NSJSONSerialization: http://developer.apple.com/library/ios/#documentation/Foundation

Why do I get this error when I try to pass a parameter in NSURL in iOS app?

邮差的信 提交于 2019-11-28 14:36:55
This is what I have in a public method - (IBAction)methodName NSString *quoteNumber = [[self textBox] text]; NSURL *url = [[NSURL alloc] initWithString:@"http://TestSite.com/virdirectory/Webservice1/Service1.asmx/GetQuote?number=%d", quoteNumber]; The error I get is: Too many arguments to method call, expected 1, have 2 What am I doing wrong? Max The initWithString method can only accept a normal NSString, you are passing it a formatted NSString, Take a look at this code: NSURL *url = [[NSURL alloc] initWithString:[NSString stringWithFormat:@"http://TestSite.com/virdirectory/Webservice1

Need to convert NSData to NSArray

佐手、 提交于 2019-11-28 14:14:57
I am pulling down a plist from a URL using an NSURLConnection, which returns an NSData object. I would like to convert this to an NSArray. Can anyone help me? I am refactoring a method that currently does a synchronous request to the URL, using arrayWithContentsOfURL: to get the NSArray. Thanks!! Use +[NSPropertyListSerialization dataWithPropertyList:format:options:error:] to convert the data, then check if the result -isKindOfClass:[NSArray class] . Use NSKeyedArchiver for archiving object to data. NSKeyedUnarchiver for unarchiving object from data: NSArray *object = [NSKeyedUnarchiver

Swift 2.0 NSURLConnection sendSynchronousRequest

ぃ、小莉子 提交于 2019-11-28 13:04:49
I am using the code below to check for an internet connection. It was working correctly but after the Swift 2.0 update I now see an error on the line var data = NSURLConnection.sendSynchronousRequest(request, returningResponse: &response, error: nil) as NSData? saying extra argument 'error' in call. class func isConnectedToNetwork()->Bool{ var Status:Bool = false let url = NSURL(string: "http://google.com/") let request = NSMutableURLRequest(URL: url!) request.HTTPMethod = "HEAD" request.cachePolicy = NSURLRequestCachePolicy.ReloadIgnoringLocalAndRemoteCacheData request.timeoutInterval = 10.0

NSURLConnection didReceiveData not called

。_饼干妹妹 提交于 2019-11-28 11:27:37
I've read through tons of messages saying the same thing all over again : when you use a NSURLConnection, delegate methods are not called . I understand that Apple's doc are incomplete and reference deprecated methods, which is a shame, but I can't seem to find a solution. Code for the request is there : // Create request NSURL *urlObj = [NSURL URLWithString:url]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:urlObj cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]; [request setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"]; if (![NSURLConnection

NSURLConnection delegate method

泪湿孤枕 提交于 2019-11-28 10:07:15
I am having a hard time to find any examples for NSURLConnection delegate method implementations. I want to send data with a HTTP post with a button click. Not sure how to make a "submitting" screen and "submitted". (I know how to use spinner and will use them) I am using this code under a botton click action, but unable to use any delegate stuff. Not sure how to implement them with my current set up. NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString:@"http://myURL.com"]]; [request setHTTPMethod:@"POST"]; NSString *postString = [wait

MITM attack reported on deprecated NSURLConnectionDelegate

你离开我真会死。 提交于 2019-11-28 09:36:37
问题 I have an Objective-C project whose .ipa was tested with this tool online: https://www.immuniweb.com/mobile It reports that my app has a high risk security issue, pointing to the canAuthenticateAgainstProtectionSpace in the NSURLConnectionDelegate protocol. This method has been deprecated by iOS after 8.0 version. My app is not using it directly anywhere and I suppose this is not used by apple also even indirectly, since it is deprecated. I tried a sample ipa (new project with nothing in it)