tags:

views:

685

answers:

2

Here is my scenario: I am building a location finder using the iPhone mapkit. I have an array stored in the application delegate to hold the information about the location of a store (name, address, etc.). When a certain button is pressed, a view slides in with a textfield and a button which performs a lookup of the users input, and returns all of the necessary information.

All of this works fine and the points get plotted onto the map. However, if I go and try to do a search a second time, the application crashes. I am trying to remove all of the objects from the array when the xml parser begins:

- (void)parserDidStartDocument:(NSXMLParser *)parser {
    [dataTempForSearch removeAllObjects];
}

and the debugger simply puts an arrow on the method call with no real explanation as to why...

Has anyone run into a scenario like this before? any thoughts as to why this might be happening only on the second time the action is performed?

+1  A: 

It's hard to tell based on just that one line of code. It's probably a memory management issue, but what specifically I can't say.

Shots in the dark: I would destroy and re-create my parser each time I did a search. I would also clear the dataTempForSearch immediately after passing the data to the app delegate, not right when you go to do another search.

Kenny Winker
You're right, it was a memory management issue. I was releasing the dataTempForSearch in the second view each time, so the next time I went to access it, it was released and the compiler didn't know where to look...Thanks for the eye opener!
rson
+1  A: 

MapKit has some very nasty problems. When you get that odd behaviour of the debugger putting an arrow at that line, take a look at the call stack provided to you (this can be seen in debug mode on the left side usually). I'll bet you it's to do with MapKit.

jbrennan