我的 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 建议的那样,你可以尝试像这样找到僵尸:
我发现这个替代方案更方便:
- 点击“运行按钮下拉菜单”
- 从列表中选择
个人资料
- “Instruments”程序应该打开,您还可以在其中选择
Zombies
- 现在您可以与您的应用交互并尝试引发错误
- 一旦发生错误,您应该会收到有关对象何时被释放并因此被释放的提示。
(来源:dimzzy.com)
关于iphone - 打开模态视图时的 EXC_BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8862998/