打开模态视图时EXC_BAD_ACCESS

时间:2012-01-14 14:57:05

标签: iphone objective-c exc-bad-access

我的iPhone应用程序出现问题,我得到EXC_BAD_ACCESS,我有一些内存泄漏,但现在已经修复了,所以我不确定是什么时候发生的。我意识到我没有提供很多信息,但我真的不知道发生了什么。

初始屏幕打开,我有许多按钮。点击第一个按钮,该按钮运行以下代码并打开模态视图:

-(IBAction)newWorkoutButton
{
    newWorkoutViewController .loadedFromRootViewController = @"YES";
    [self presentModalViewController:newWorkoutViewController animated:YES];
}

屏幕冻结,位于以下代码中:

#import <UIKit/UIKit.h>
#import <objc/runtime.h>
#import <CoreLocation/CoreLocation.h>


int main(int argc, char *argv[]) 
{
    Method getDistanceFrom = class_getInstanceMethod([CLLocation class], @selector(getDistanceFrom:));
    class_addMethod([CLLocation class], @selector(distanceFromLocation:), method_getImplementation(getDistanceFrom), method_getTypeEncoding(getDistanceFrom));

    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    int retVal = UIApplicationMain(argc, argv, nil, nil); // ERROR HAPPENING HERE
    [pool release];
    return retVal;
}

1 个答案:

答案 0 :(得分:1)

像Aleks建议你可以尝试找到这样的僵尸:

我觉得这个替代方案更方便:

  1. 点击“运行按钮下拉列表”
  2. 从列表中选择Profile
  3. 应打开“乐器”程序,您也可以选择Zombies
  4. 现在您可以与您的应用互动并尝试导致错误
  5. 一旦发生错误,您应该获得关于何时释放对象并因此解除分配的提示。
  6. Zombies http://www.dimzzy.com/blog/wp-content/uploads/2011/02/leaky-zombies-tool.png