問(wèn)題描述
**2015-11-03 17:50:27.798 Periferica[12033:4104907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[1]'**
***** First throw call stack:**
**(0x18499cf48 0x19954ff80 0x18488b7c8 0x18488b660 0x1000414d4 0x100041150 0x189fa5324 0x18a1d3acc 0x18a1d7e0c 0x18a1d4f50 0x18e7bb7c4 0x18e7bbb44 0x184954544 0x184953fd8 0x184951cd8 0x184880ca0 0x189f9e1c8 0x189f98ffc 0x1000416f4 0x199d9e8b8)**
**libc++abi.dylib: terminating with uncaught exception of type NSException**
解決方法
xcode gdb/lldb調(diào)試命令ps:主要學(xué)到的是bt
ios崩潰的解決
iOS捕獲異常,常用的異常處理方法
讓XCode的 Stack Trace信息可讀
整理平時(shí)IOS調(diào)試中遇到的問(wèn)題
相關(guān)代碼
方法一:main.m文件
int main(int argc, char * argv[]) {
@autoreleasepool {
int retVal;
@try {
retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
@catch (NSException *exception) {
NSLog(@"CRASH: %@", exception);
NSLog(@"Stack Trace: %@", [exception callStackSymbols]);
}
@finally {
NSLog(@"finally");
}
return retVal;
}
}
方法二:AppDelegate
void uncaughtExceptionHandler(NSException *exception) {
/**
* 獲取異常崩潰信息
*/
NSArray *callStack = [exception callStackSymbols];
NSString *reason = [exception reason];
NSString *name = [exception name];
NSString *content = [NSString stringWithFormat:@"========異常錯(cuò)誤報(bào)告========\nname:%@\nreason:\n%@\ncallStackSymbols:\n%@",name,reason,[callStack componentsJoinedByString:@"\n"]];
/**
* 把異常崩潰信息發(fā)送至開(kāi)發(fā)者郵件
*/
NSMutableString *mailUrl = [NSMutableString string];
[mailUrl appendString:@"642974280@qq.com"];
[mailUrl appendString:@"?subject=程序異常崩潰铅匹,請(qǐng)配合發(fā)送異常報(bào)告,謝謝合作泣崩!"];
[mailUrl appendFormat:@"&body=%@", content];
// 打開(kāi)地址
NSString *mailPath = [mailUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:mailPath]];
}
遺留問(wèn)題:
當(dāng)錯(cuò)誤來(lái)自第三方庫(kù)的時(shí)候你就懵了。