views:

326

answers:

1

Hello, my iphone app crashes unexpectedly and looking at the crash log I can't tell where my code is doing something wrong. All I get in the stack are calls to the framework it's self.

Any help? please!

this is the link to the crash log (rather than copy paste it all here) http://www.megaupload.com/?d=CTWWNUN1

thanks!!!

+2  A: 

Looks like you're crashing at mach_msg_trap, the function that handles Objective-C message passing. This is often a sign that you're doing one of two things:

  1. You have a memory management issue somewhere - you're trying to call a selector on an object that's already been released, you're overreleasing an object, or something similar.
  2. You're not being thread-safe in some framework. This can be especially tricky in UIKit (most of the UI* elements that the iPhone uses), where you're not allowed to update the screen from any thread other than the main thread.

Look at using Instruments to check your object allocation and leaks, and double-check that you're respecting thread safety properly.

Tim
Amazing answer!! thanks a lot! I'll try some stuff out.I'm pretty sure it has something to do with the thread safe in UIKit. Any ideas on how preventing this or best practices on being thread safe when using UIKit? For example: if I do [someUITableView reloadData] I should ensure that it's executed by the main thread, right?
nico
Pretty much. The idea is that you shouldn't be calling or committing anything that will cause an animation (in a table view, this means reloading data, inserting/deleting rows/sections) from anywhere other than the main thread. If your app is single-threaded, no worries; otherwise, just use the performSelectorOnMainThread: method.
Tim