程序调试
● 调用堆栈
我们先写一个 Demo 演示一下错误
- (void)viewDidLoad {
[super viewDidLoad];
[self testDemo];
}
- (void)testDemo {
NSString *str = nil;
NSArray *array = @[@"hello word!", str];
NSLog(@"%@", array);
}
运行后 程序很听话的报错了!
**2016-11-09 23:02:58.839 01-Bugly[976:81766] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[1]'**
***** First throw call stack:**
**(**
** 0 CoreFoundation 0x000000011150034b __exceptionPreprocess + 171**
** 1 libobjc.A.dylib 0x0000000110f6121e objc_exception_throw + 48**
** 2 CoreFoundation 0x00000001114103b3 -[__NSPlaceholderArray initWithObjects:count:] + 275**
** 3 CoreFoundation 0x00000001114175c4 +[NSArray arrayWithObjects:count:] + 52**
** 4 01-Bugly 0x000000010fd06332 -[ViewController testDemo] + 98**
** 5 01-Bugly 0x000000010fd062c9 -[ViewController viewDidLoad] + 7