1

EXC_BAD_ACCESS関数の最後の行 (webData) を実行すると、が得られました。

-(void)requestSoap{
NSString *requestUrl = @"http://www.website.com/webservice.php";
NSString *soapMessage = @"the soap message";
//website and soapmessage are valid in original code.

 NSError **error;
 NSURLResponse *response;

 //Convert parameter string to url
 NSURL *url = [NSURL URLWithString:requestUrl];
 NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10];

 NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];

 //Create an XML message for webservice
 [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
 [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
 [theRequest setHTTPMethod:@"POST"];
 [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];

 NSData *webData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:error];
}

私がネット上で読んだことは、ほとんどの場合記憶に関するものだったので、私は何かをリリースしないように努めました.

コードをデバッグすると、次の(NSZombieEnabled = YES)ようになります。

[Session started at 2010-05-31 15:56:13 +0200.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1461.2) (Fri Mar  5 04:43:10 UTC 2010)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 19856.
test(19856) malloc: recording malloc stacks to disk using standard recorder
test(19856) malloc: enabling scribbling to detect mods to free blocks
test(19856) malloc: process 19832 no longer exists, stack logs deleted from /tmp/stack-logs.19832.test.w9Ek4L.index
test(19856) malloc: stack logs being written into /tmp/stack-logs.19856.test.URRpQF.index
Program received signal:  “EXC_BAD_ACCESS”.

誰も手がかりを持っていますか?

4

1 に答える 1

1

error変数の定義に誤りがあります。使用する必要があります

NSError *error;

それ以外の

NSError **error; // There is a '*' too much here

次に、それを に渡すときは、sendSynchronousRequest:returningResponse:error:次を使用してそのアドレスを渡す必要があります&error

[NSURLConnection sendSynchronousRequest:theRequest
                      returningResponse:&response
                                  error:&error];
于 2010-05-31T16:47:04.570 に答える