iphone - 打开模态视图时的 EXC_BAD_ACCESS

标签 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;
}

最佳答案

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

我发现这个替代方案更方便:

  1. 点击“运行按钮下拉菜单”
  2. 从列表中选择个人资料
  3. “Instruments”程序应该打开,您还可以在其中选择Zombies
  4. 现在您可以与您的应用交互并尝试引发错误
  5. 一旦发生错误,您应该会收到有关对象何时被释放并因此被释放的提示。

Zombies
(来源:dimzzy.com)

关于iphone - 打开模态视图时的 EXC_BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8862998/

相关文章:

iphone - ffmpeg 在 iOS 上的使用

objective-c - 如何防止 "_OBJC_IVAR_$_UIPickerView._backgroundView symbol not found"错误?

ios - 如何获取 CGPDFDictionaryRef 键

objective-c - 如何在非 ARC 世界中使用 NSMutableDictionary 避免 EXC_BAD_ACCESS?

iphone - 地址簿 + UITableView 索引 iPhone

iphone - 美国的NSLocale?

iPhone应用程序内部录音

objective-c - subview 没有收到触摸

iphone - 方法末尾的EXC_BAD_ACCESS

iPhone - 将 IBOutlet 设置为 nil 时的 EXC_BAD_ACCESS - 内存管理