Select to view content in your preferred language

Running AGSRouteTask two times in a row causes an exception : EXC_BAD_ACCESS

1107
4
05-05-2011 08:14 AM
MiriEshel
Esri Contributor
Hi,

Using the GARouteTAsk in ver 1.8, If I try to run a Routetask two times in a row, It crashes in line :
self.routeResult = [routeTaskResult.routeResults lastObject];

Is there any way to reset the routeTaskResult?

Hope I finished my questions with RouteTask....

Have a nice weekend,
Thanks a lot,
Miri
0 Kudos
4 Replies
NimeshJarecha
Esri Regular Contributor
Miri,

Are you seeing the crash with sample or your own project.
It'll helpful to look into if you provide more information.

Regards,
Nimesh
0 Kudos
NimeshJarecha
Esri Regular Contributor
The crash happens because of over-realeasing. Please comment out code lines as following and you'll be able to execute route task multiple times.

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

The directionsGraphic taken from dirArray is an autoreleased object and you don't need to explicitly release it.

I saw, at many places you are releasing autoreleased objects. One of them is stopGraphic. Also, you are releasing a callout template, which will create crash when you tap on the graphic as callout template is released. I would recommend creating a retain properties for callout templates so it'll be available when needed.

Hope this helps!

Regards,
Nimesh
0 Kudos
MiriEshel
Esri Contributor
Hi Nimesh,

Thank you so much for your help. I will check it tomoroow.
1. Were you able to run the project or you just looked at the code?
2. Did you see the other problem with the sequence? ("Sequence property of AGSStopGraphic does not seem to influence ") in this sam app.

Thanks again and again, I can't tell you how grateful I am.

Miri
0 Kudos
NimeshJarecha
Esri Regular Contributor
1. Yes, I was able to run the project and reproduce. With the solution i provided, no longer able to reproduce.
2. I'll have a look at it as soon as get a chance.

Regards,
Nimesh
0 Kudos