Dan Morgan
Dan Morgan

Reputation: 2500

iPhone Bug App bug Question and challenge

I've got a really annoying bug in my app. It's driving me crazy and I'm sure it's beyond my skill level as I am learning as I go.

Here is the initial rundown of the bug: A shot in the dark - Application bug

However I have found a way to consistently reproduce the bug (only on the device not in the simulator)

First you create a new Pool and save it. Then add 20 blank time entires into one day. Save it and this is where the problems begin. (when you go back to the main detail view the tableview has put itself out of editing mode with being told to do so). Now if you go back to the day to see the time entries you just added they are still there.

If you go back to the main overall tableview listing all pools and now go back to the day you added the times they have disappeared.

Add one time and it all saves fine. Add twenty and it doesn't save.

Main Menu listing Pools:

https://farm4.static.flickr.com/3503/3301053744_0325d5bc2c.jpg?v=0

Detail view:

https://farm4.static.flickr.com/3546/3300222271_223d2c74e9.jpg?v=0

Edit View:

https://farm4.static.flickr.com/3625/3300222887_b02c3e2052.jpg?v=0

Time Edit View:

https://farm4.static.flickr.com/3547/3301056092_8d3ab78225.jpg?v=0

Add a time:

https://farm4.static.flickr.com/3635/3300224157_14c30cf58f.jpg?v=0

I'd appreciate any more guesses.

Upvotes: 0

Views: 322

Answers (3)

Dan Morgan
Dan Morgan

Reputation: 2500

Thanks for all your answers. It's now fixed.

For those interested I'd forgotten to add a cellidentifer in the XIB of my cell subclass.

cellForRow: method was therefore creating a new cell every time. The memory got filled up very quick. It then seemed as though my app was automatically trying to cut the fat by forcing another tableView out of editing mode and not managing my instances properly.

Again it's a memory problem. Isn't this always the case!?!

The clue was a one off 101 error in the console indicating my app was using too much memory. Oh and a slow scrolling tableView.

Upvotes: 0

Ashley Clark
Ashley Clark

Reputation: 8823

If you haven't already done so, I'd recommend turning on NSZombie support and seeing if you're using any of your objects after they've been freed. As far as I know this can be turned on in the simulator and on the device.

Upvotes: 1

Mark Bessey
Mark Bessey

Reputation: 19782

Most likely, you're failing to retain some object somewhere along the way. When an object gets released and then the memory is re-used for something else, you'll get all sorts of bad behavior, including crashes, or mysterious "disappearance" of other objects.

One thing you can try is putting breakpoints into the -dealloc method of your custom classes. Then you can see where they're getting deallocated from. Most likely though, this will end up being when the AutoreleasePool gets drained, which won't tell you much.

Alternatively, look into using some of the memory debugging tools built into Cocoa.

That document is for Mac OS X, but I think most all of this will work in the iPhone simulator, at least. I know that your bug "doesn't happen" in the simulator, but that really only means that the symptoms are different, and you're not noticing them.

Upvotes: 0

Related Questions