1

I am using the following code to generate and parse the XML. The method [self checksigninSucess]; is called and the UITextField values are set while pressing a "Sign IN" button.

-(void)checksigninSucess{

NSString* content = [NSString stringWithFormat:@"http://www.anball/login_check.php?email=%@&password=%@",emailField.text,passwordField.text];

NSData *xml = [NSData dataWithContentsOfURL: [NSURL URLWithString:content]];

NSLog(@"URLXML %@",[NSURL URLWithString:content]);

self.parser=[NSXMLParser alloc]initWithData:xml];
[self.parser setDelegate:self];
[self.parser parse];
[self.parser release];
self.parser=nil;
}

But my problem is that NSData holds the values which I enter in the text fields for the first time only. When I press the "Sign In" button for the second time with different email and password , NSData holds the same URL it generated before. How can I clear the values held by NSData for the next try.

Stephen
  • 1,737
  • 2
  • 26
  • 37
Muhammed Sadiq.HS
  • 773
  • 1
  • 11
  • 35
  • Are you sure the content string is different the second time? Maybe you are not setting the text field values right? – TheEye Nov 18 '11 at 10:02
  • Print the log of your text field – Maulik Nov 18 '11 at 10:04
  • NOP!!When i print the URL ([NSURL URLWithString:content]) in console it gives the modified URL but not the NSData!! – Muhammed Sadiq.HS Nov 18 '11 at 10:05
  • refer this link for clear caching http://stackoverflow.com/questions/405151/is-it-possible-to-prevent-an-nsurlrequest-from-caching-data-or-remove-cached-dat – Maulik Nov 18 '11 at 10:33

2 Answers2

3

Why do you need to use NSData? Use NSString instead, as follows.

self.parser=[[NSXMLParser alloc] initWithContentsOfURL:[NSURL URLWithString:content]];

[self.parser setDelegate:self];
[self.parser parse];
[self.parser release];
self.parser=nil;
Bert
  • 80,741
  • 17
  • 199
  • 164
2

Use this line instead, to prevent Caching of data

NSData *xml = [NSData dataWithContentsOfURL: [NSURL URLWithString:content] options:NSDataReadingUncached error:nil];

Using second variant of function

+ (id)dataWithContentsOfURL:(NSURL *)aURL options:(NSDataReadingOptions)mask error:(NSError **)errorPtr

See NSDataReadingOptions masks

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSData_Class/Reference/Reference.html#//apple_ref/doc/uid/20000172-307810

Marek Sebera
  • 39,650
  • 37
  • 158
  • 244
  • 2
    please, try to describe how exactly it `does not work` and use less of exclamation marks. We can't help you without you taking part. – Marek Sebera Nov 18 '11 at 10:17