线程1:信号SIGBRT
线程1:信号SIGBRT
运行我的Xcode项目时出现错误。我的应用程序一直工作,所以我真的看不出为什么它现在不起作用了。有人有什么想法吗?我发现这是因为我调用了一个无效的方法所致。我似乎找不到这个错误在哪里.. 有人知道吗?
错误信息:
2014-02-25 11:52:06.784 Chemie Xpert - PSE[1381:70b] *** 因为未捕获的异常 'NSUnknownKeyException' 终止应用,原因:'[setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.' *** First throw call stack: ( 0 CoreFoundation 0x023625e4 __exceptionPreprocess + 180 1 libobjc.A.dylib 0x014bc8b6 objc_exception_throw + 44 2 CoreFoundation 0x023f26a1 -[NSException raise] + 17 3 Foundation 0x00f709ee -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282 4 Foundation 0x00edccfb _NSSetUsingKeyValueSetter + 88 5 Foundation 0x00edc253 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267 6 Foundation 0x00f3e70a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412 7 UIKit 0x002bfa15 -[UIRuntimeOutletConnection connect] + 106 8 libobjc.A.dylib 0x014ce7d2 -[NSObject performSelector:] + 62 9 CoreFoundation 0x0235db6a -[NSArray makeObjectsPerformSelector:] + 314 10 UIKit 0x002be56e -[UINib instantiateWithOwner:options:] + 1417 11 UIKit 0x002c02fb -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 165 12 UIKit 0x0001d3bb -[UIApplication _loadMainNibFileNamed:bundle:] + 58 13 UIKit 0x0001d6e9 -[UIApplication _loadMainInterfaceFile] + 245 14 UIKit 0x0001c28f -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 543 15 UIKit 0x0003087c -[UIApplication handleEvent:withNewEvent:] + 3447 16 UIKit 0x00030de9 -[UIApplication sendEvent:] + 85 17 UIKit 0x0001e025 _UIApplicationHandleEvent + 736 18 GraphicsServices 0x022c02f6 _PurpleEventCallback + 776 19 GraphicsServices 0x022bfe01 PurpleEventCallback + 46 20 CoreFoundation 0x022ddd65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53 21 CoreFoundation 0x022dda9b __CFRunLoopDoSource1 + 523 22 CoreFoundation 0x0230877c __CFRunLoopRun + 2156 23 CoreFoundation 0x02307ac3 CFRunLoopRunSpecific + 467 24 CoreFoundation 0x023078db CFRunLoopRunInMode + 123 25 UIKit 0x0001badd -[UIApplication _run] + 840 26 UIKit 0x0001dd3b UIApplicationMain + 1225 27 Chemie Xpert - PSE 0x0000247d main + 141 28 libdyld.dylib 0x0598d70d start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
我的代码:
main.m:
#import#import "AppDelegate.h" int main(int argc, char *argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } }
ViewController.m:
#import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize webview; - (void)viewDidLoad { [super viewDidLoad]; NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"localHTML"]; NSURL *url = [NSURL fileURLWithPath:path]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [webview loadRequest:request]; webview.scalesPageToFit = YES; webview.scrollView.bounces = NO; webview.scrollView.minimumZoomScale = 1; webview.scrollView.bouncesZoom = FALSE; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (BOOL)prefersStatusBarHidden { return YES; } @end
(Thread 1: signal SIGBRT)问题的出现可能是因为webview被设置为IBOutlet。
解决方法可以尝试以下步骤:
1. 检查ViewController.h文件,确保已经正确导入UIKit库。
2. 确保在ViewController.h文件中正确声明了webview,并设置为IBOutlet。示例代码如下:
#importViewController : UIViewController{ IBOutlet UIWebView *webview; } @property (nonatomic, retain) UIWebView *webview;
3. 检查故障代码,查看是否有其他地方对webview进行了无效的操作。
4. 如果问题仍然存在,可以尝试重新连接IBOutlet,或者重新创建IBOutlet连接。
5. 如果以上方法都没有解决问题,可能需要重新创建或者更新webview的引用。
以上是解决(Thread 1: signal SIGBRT)问题的一些常见方法,可以根据具体情况选择适合的解决方法。