iPhone Error: EXC_BAD_ACCESS

Hi, I need help, I am getting an error on iphone app. I am an iPhone newbie and this is my first app, thank you for your help.

Error message from console:
Program received signal: “EXC BADACCESS”.
kill
error while killing target (killing anyway): warning: error on line 1987 of "/SourceCache/gdb/gdb-966/src/gdb/macosx/macosx-nat-inferior.c" in function "macosx kill_inferiorsafe": (os/kern) failure (0x5x)
quit

Here is my code:

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];

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/"> "
"<soap:Body> "
"<MeetingProgramMenu xmlns="http://www.meeting.org/"> "
"<MeetingID>%@</MeetingID> "
"</MeetingProgramMenu> "
"</soap:Body> "
"</soap:Envelope> ", meetingID
];
NSLog(soapMessage);

NSURL *url = [NSURL URLWithString:@"http://sandbox.meeting.org/webservice/meeting.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://www.meeting.org/MeetingProgramMenu" 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];
}
else
{
NSLog(@"theConnection is NULL");
}

cellSize = CGSizeMake([tblSimpleTable bounds].size.width, 60);
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 4;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//if ([stories1 count] >= 0)

if(section == 0)
return [stories1 count];
else if(section == 1)
return [stories2 count];
else if(section == 2)
return [stories3 count];
else if(section == 3)
return [stories4 count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
//cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}

// Set up the cell...
if(indexPath.section == 0){
cell.text = [stories1 objectAtIndex:indexPath.row];
}else if(indexPath.section == 1){
cell.text = [stories2 objectAtIndex:indexPath.row];
}else if(indexPath.section == 2){
cell.text = [stories3 objectAtIndex:indexPath.row];
//}else if(indexPath.section == 3){
// cell.text = [stories4 objectAtIndex:indexPath.row];
}
return cell;
}
- (IBAction) LoadMeeting:(NSMutableArray *)meetingObj{
NSString *meetingTitle = [meetingObj objectForKey: @"name"];
meetingID = [meetingObj objectForKey: @"eventid"];
NSString *meetingAmos = [meetingObj objectForKey: @"amos"];
NSString *meetingRS = [meetingObj objectForKey: @"room_sched"];
NSString *meetingCal = [meetingObj objectForKey: @"cal"];

self.navigationItem.title = meetingTitle;
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
[webData setLength: 0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[webData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(@"ERROR with theConenction");
[connection release];
[webData release];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
stories1 = [[NSMutableArray alloc] init];
stories2 = [[NSMutableArray alloc] init];
stories3 = [[NSMutableArray alloc] init];
stories4 = [[NSMutableArray alloc] init];

NSLog(@"DONE. Received Bytes: %d", [webData length]);
NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
//NSLog(theXML);
[theXML release];

if( rssParser )
{
[rssParser release];
}

rssParser = [[NSXMLParser alloc] initWithData: webData];
[rssParser setDelegate: self];
[rssParser setShouldResolveExternalEntities: YES];
[rssParser parse];

[connection release];
[webData release];
}
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError {
NSString * errorString = [NSString stringWithFormat:@"Unable to download story feed from web site (Error code %i )", [parseError code]];
NSLog(@"error parsing XML: %@", errorString);

UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Error loading content" message:errorString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[errorAlert show];
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
NSLog(@"found this element: %@", elementName);
currentElement = [elementName copy];
if ([elementName isEqualToString:@"Menus"]) {
// clear out our story item caches...
item = [[NSMutableDictionary alloc] init];
currentTitle = [[NSMutableString alloc] init];
currentDate = [[NSMutableString alloc] init];
currentSummary = [[NSMutableString alloc] init];
currentLink = [[NSMutableString alloc] init];
}

}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{
NSLog(@"ended element: %@", elementName);
if ([elementName isEqualToString:@"Menus"]) {
// save values to an item, then store that item into the array...
[item setObject:currentTitle forKey:@"category"];
[item setObject:currentLink forKey:@"tablename"];
[item setObject:currentSummary forKey:@"ID"];
[item setObject:currentDate forKey:@"menu"];

if ([currentTitle isEqualToString:@"Date"])
{
[stories1 addObject:[item copy]];
}
if ([currentTitle isEqualToString:@"Session"])
{
[stories2 addObject:[item copy]];
}
if ([currentTitle isEqualToString:@"Room"])
{
[stories3 addObject:[item copy]];
}
if ([currentTitle isEqualToString:@"Cal"])
{
[stories4 addObject:[item copy]];
}
NSLog(@"adding story: %@", currentTitle);
}

}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
NSLog(@"found characters: %@", string);
// save the characters for the current item...
if ([currentElement isEqualToString:@"category"]) {
[currentTitle appendString:string];
} else if ([currentElement isEqualToString:@"tablename"]) {
[currentLink appendString:string];
} else if ([currentElement isEqualToString:@"ID"]) {
[currentSummary appendString:string];
} else if ([currentElement isEqualToString:@"menu"]) {
[currentDate appendString:string];
}

}
- (void)parserDidEndDocument:(NSXMLParser *)parser {

[activityIndicator stopAnimating];
[activityIndicator removeFromSuperview];

NSLog(@"all done!");
//NSLog(@"stories array has %d items", [stories count]);
[tblSimpleTable reloadData];
}
- (void)dealloc {
[currentElement release];
[rssParser release];
[stories1 release];
[stories2 release];
[stories3 release];
[stories4 release];
[item release];
[currentTitle release];
[currentDate release];
[currentSummary release];
[currentLink release];
[webData release];
[soapResults release];

[super dealloc];
}

MacBookPro, Mac OS X (10.6.2)

Posted on Mar 30, 2010 12:30 PM

Reply
6 replies

Mar 30, 2010 12:44 PM in response to stokbs

stokbs wrote:
Hi, I need help, I am getting an error on iphone app. I am an iPhone newbie and this is my first app, thank you for your help.


Welcome to Apple's discussion groups.

Error message from console:
Program received signal: “EXC BADACCESS”.
kill
error while killing target (killing anyway): warning: error on line 1987 of "/SourceCache/gdb/gdb-966/src/gdb/macosx/macosx-nat-inferior.c" in function "macosx kill_inferiorsafe": (os/kern) failure (0x5x)


That error means your code tried to reference an invalid address. Here's what one source says about it:

http://www.codza.com/how-to-debug-excbadaccess-on-iphone

Do you know what line in your source code is line 1987? If you can determine that it would help a lot in isolating the problem. (Sorry, I'm not currently an Xcoder, so I have no advice for you on that.)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

iPhone Error: EXC_BAD_ACCESS

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.