0

.mファイルに次のコードがあります。

- (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]; 
}

また、自動参照カウントモードでは自動解放が利用できないようになっています。

次の行に問題があるようです。

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

どうすればこれを解決できますか?

4

1 に答える 1

2

autorelease通話を削除するだけです。ARC(自動参照カウント)を使用している場合は、メモリ管理について心配する必要はありません。

于 2013-02-03T20:19:28.407 に答える