开发者

NSMutableArray removeAllObjects issue

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 p开发者_如何学Pythonlotted 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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜