Select to view content in your preferred language

Next and prev Buttons for routing purpose causes EXC_BAD_ACCESS in my app.

1015
3
05-11-2011 06:21 AM
MiriEshel
Esri Contributor
Hi everybody,

Sorry I'm flooding the forum with questions. I'm almost at the end of migrating an application from 1.0 to 1.8. I'm alone in this battle so I must consult with you guys.

I'm trying to combine the nextBtn and prevBtn functionalities of the Routing Sample in my code. When I get to the line [self.currentDirectionGraphic = [directions.graphics objectAtIndex:_directionIndex]; I get the nasty EXC_BAD_ACCESS. I tried almost everything and couldn't find the problem. I'm sure one of you can easily find it.
It is fairly to reproduce.
I put my project myRouting.zip under ftp://ftp.plm.co.il/mirie/.
(When it opens, don't click the next & prev buttons.)
When it opens, click on the right second button of the bottom Tab Bar (with an arrow icon).
When this view opens, click on the blue button in the right upper side (it has default values already for two addresses).
It finally shows a route. Then click on the nextBtn and see how it blows away....

Sorry again.... I promise that when I'll be able to answer questions in the forum, I will do it with pleasure.

Thanks a lot,
Miri
0 Kudos
3 Replies
NimeshJarecha
Esri Regular Contributor
The same reason of thread...http://forums.arcgis.com/threads/29753-Running-AGSRouteTask-two-times-in-a-row-causes-an-exception-E...

Once you comment out code lines as following, it'll work.

AGSDirectionGraphic *directionsGraphic = [dirArray objectAtIndex:i];
NSString *directionString = directionsGraphic.text;
//[directionsGraphic release];
//directionsGraphic = nil;

Regards,
Nimesh
0 Kudos
MiriEshel
Esri Contributor
Nimesh,

I see that the crash happens because of the same over-realeasing.
I'm so afraid of memory leak, that I release everything immediately after I use them.

Thanks again,
Miri
0 Kudos
NimeshJarecha
Esri Regular Contributor
I would recommend going through Apple's memory management documentation. I rule of thumb is to release (Release or Autorelease) only objects which you own (objects created with Alloc or New keywords).

Regards,
Nimesh
0 Kudos