1

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
  • does it crash if you comment this line out? How about if you wrote a for loop to removeObject on each object? Try these as debugging aids. Commented Nov 9, 2009 at 23:40

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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!
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.