ios开放中我们会遇到很多各种崩溃信息,我们可以利用调用堆栈的崩溃信息和bugly分析.
例如一下Dome,我创建了一个空对象,插入数组.
一:看调用堆栈.
从以上调用堆栈我们可以看出,[UIWindow makeKeyAndVisible]程序启动 - >[ViewController viewDidLoad] -> [__NSPlaceholderArray initWithObjects:count:]程序奔溃.
崩溃原因:插入数组一个空的对象;
二、通过bugly框架的崩溃信息.
1.首先pod 'bugly' 导入框架.
2.在工程的AppDelegate.m文件导入头文件#import<Bugly/Bugly.h>
3. application方法中调用[Bugly startWithAppId:@"此处替换为你的AppId"];
注意此步骤写在方法的最前面.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[Bugly startWithAppId:@"此处替换为你的AppId"];
return YES;
}
调试中关于NSLog的运用:
在PCH文件中写入一下代码:
#ifdef __OBJC__
#ifdef DEBUG
#define NSLog(...) NSLog(__VA_ARGS__)
#else
#define NSLog(...)
#endif
#end if
调试阶段(Debug)的NSLog打印,上架阶段(Release)不打印.