Question

I have the following code in my .m file:

- (IBAction)LoginButton:(id)sender {

// create string contains url address for php file, the file name is phpFile.php, it receives parameter :name
NSString *strURL = [NSString stringWithFormat:@"http://www.myURL.com/verify.php?Email=%@",Email.text];

// to execute php code
NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];

// to receive the returend value
NSString *strResult = [[[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding]autorelease];

NSLog(@"%@", strResult);

UIAlertView *alert = [[UIAlertView alloc]
                      initWithTitle:@"Result:"
                      message:strResult
                      delegate:nil
                      cancelButtonTitle:@"Okay"
                      otherButtonTitles:nil];    
                      [alert show]; 
}

And I am getting that autorelease is unavailable in automatic reference counting mode.

It seems to be an issue with the following line:

NSString *strResult = [[[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding]autorelease];

How can I solve this?

Was it helpful?

Solution

Just delete the autorelease call; if you are using ARC (Automatic Reference Counting) you don't need to worry about memory management.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top