1

This is strange.. My app worked good before I duplicated the target to make a paid version of my app.. When I want to show a UIViewController, it is loaded, and shown, but my application crashes, and gives me this error in the device log:

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libobjc.A.dylib                 0x341c2fbc objc_msgSend + 16
1   UIKit                           0x3735fdfe -[UINavigationController topViewController] + 46
2   UIKit                           0x37395ae4 -[UINavigationController viewDidDisappear:] + 80
3   UIKit                           0x373636ae -[UIViewController _setViewAppearState:isAnimating:] + 138
4   UIKit                           0x373beaea -[UIViewController _endAppearanceTransition:] + 258
5   UIKit                           0x373ecec8 -[UIViewController endAppearanceTransition] + 16
6   UIKit                           0x3741cf04 -[UIWindowController transitionViewDidComplete:fromView:toView:] + 1404
7   UIKit                           0x373bc934 -[UITransitionView notifyDidCompleteTransition:] + 140
8   UIKit                           0x373bc7b8 -[UITransitionView _didCompleteTransition:] + 896
9   UIKit                           0x37336814 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 464
10  UIKit                           0x3733bfb2 -[UIViewAnimationState animationDidStop:finished:] + 46
11  QuartzCore                      0x34a8dba0 CA::Layer::run_animation_callbacks(void*) + 196
12  libdispatch.dylib               0x36bace86 _dispatch_main_queue_callback_4CF$VARIANT$up + 190
13  CoreFoundation                  0x33f4b2d6 __CFRunLoopRun + 1262
14  CoreFoundation                  0x33ece4d6 CFRunLoopRunSpecific + 294
15  CoreFoundation                  0x33ece39e CFRunLoopRunInMode + 98
16  GraphicsServices                0x30752fc6 GSEventRunModal + 150
17  UIKit                           0x3734f73c UIApplicationMain + 1084
18  MyApp                       0x00002674 main (main.m:15)
19  MyApp                       0x00002624 start + 32

Where is my error? Can anyone help me?

ipmcc
  • 29,581
  • 5
  • 84
  • 147
Jayyrus
  • 12,961
  • 41
  • 132
  • 214
  • Xcode can help you a great deal to find Zombies. http://stackoverflow.com/questions/2190227/how-do-i-setup-nszombieenabled-in-xcode-4/8863063#8863063 this will show you when the retain count of a given object changed – Besi May 08 '12 at 08:56

1 Answers1

1

This looks like a zombie object access, just on it's face. Not sure why duping the target alone would cause this, but have you tried profiling your app with the Zombies instrument in the simulator?

EDIT:

Yup. OK, now you know what's happening. Again, it's hard for me to imagine how merely duplicating a target could cause this to happen. An object that should be being retained is not being retained. There are any number of causes for this, but one potential cause is a @property that should be declared retain or copy, but is declared assign. The Zombies instrument can help you out further:

Next to that error message, there should be a little arrow in a circle. If you click that it should take you to a detail view that shows you all the things that retained and released that object during it's life. This might be helpful, it might not. If the problem is that something is "overreleasing" the object, you might be able to tell from the list, but more likely the problem is that something that should retain it, isn't, and that won't show up on the list.

What might be helpful in that list is to see who created the object, because typically that will be the logical "owner" of the object (or it will pass it into the logical owner). I would go through my project, and think about the intended ownership of the object in question. Who should own this object? Why aren't they retaining it?

If you're still coming up to speed with Cocoa memory management, I recommend reading Apple's guide: Advanced Memory Management Programming Guide Fixing zombie object accesses is a rite of passage for Objective-C developers. Stick with the platform and you'll undoubtedly have many opportunities to hone your technique.

You might also consider using Automatic Reference Counting (ARC). It's meant to make it so you don't have to think about this stuff, and actually works pretty darn well.

EDIT 2:

Just occurred to me: Is it possible you were using ARC in the original target and when you duplicated the target, that setting somehow got turned off? That would certainly explain it.

AMayes
  • 1,767
  • 1
  • 16
  • 29
ipmcc
  • 29,581
  • 5
  • 84
  • 147
  • done! i receive this error: An Objective-C message was sent to a deallocated object (zombie) at address: 0x7848500. – Jayyrus Jan 15 '12 at 15:34