【发布时间】:2011-01-01 02:17:57
【问题描述】:
我在尝试创建方法的实例时遇到 EXC_BAD_ACCESS 错误。
UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(40,38,240,203)];
DetailImageViewDataSource *detail=[[DetailImageViewDataSource alloc] init];//**error line**
@implementation DetailImageViewDataSource
@synthesize webdata,xmlParser,soapResults,newImage;
-(void) startParsing
{
recordResults=FALSE;
NSString *soapMessage=[NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
"<soap:Body>\n"
"<GetImage xmlns=\"http://tempuri.org/\">\n"
"<imageID>f89df9ad-5a5d-4354-895f-356d8ce4ccfb</imageID>\n"
"</GetImage>\n"
"</soap:Body>\n"
"</soap:Envelope>\n"];
//http://192.168.2.7/ImageWebService/Service1.asmx
//http://192.168.2.7/ThesisWebServicesNew1/Service.asmx
NSLog(soapMessage);
NSURL *url=[NSURL URLWithString:@"http://192.168.2.7/ThesisWebServicesNew1/Service.asmx"];
NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:url];
NSString *msgLength=[NSString stringWithFormat:@"%d",[soapMessage length]];
[theRequest addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue:@"http://tempuri.org/GetImage" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if(theConnection)
{
webdata=[[NSMutableData data] retain];
NSLog(@"got connected");
}
else
{
NSLog(@"No Cnnection");
}
//[nameinput resignFirstResponder];
}
初始化代码
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Custom initialization
}
UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(40,38,240,203)];
[img setImage:[UIImage imageNamed:@"LARCbackground.png"]];
UITableView *tableView1=[[UITableView alloc] initWithFrame:CGRectMake(20,266,280,136) style:UITableViewStylePlain];
[tableView1 setDelegate:self];
[tableView1 setDataSource:self];
[tableView1 setAlpha:0.75];
[tableView1 setBackgroundColor:[UIColor clearColor]];
[[self view] addSubview:tableView1];
[tableView1 dealloc];
[[self view] addSubview:img];
[img dealloc];
//[imageView setImage:];
//[[self view] addSubview:imageView];
return self;
}
我在这里应用了一个断点,当我点击继续时,我得到了 exe_bad_access 错误。
我正在尝试创建一个 xmlparser 类的对象。
已经做了几个小时了.. 没有成功。请帮忙..
【问题讨论】:
-
请发布 DetailImageViewDataSource 初始化程序的代码。此外,您提到您正在尝试创建 xmlparser 的实例,但未显示该代码。
-
EXC_BAD_ACCESS 发生在哪里(哪一行)?
-
DetailImageViewDataSource *detail=[[DetailImageViewDataSource alloc] init];这是行
-
按照我最初的要求,请发布该初始化程序。
-
如果你直接打电话给
dealloc,我认为你还有很多问题。
标签: iphone objective-c xcode