如何找出这些错误。我的应用程序崩溃了 6 次(来自应用程序分析的报告)?
Posted
技术标签:
【中文标题】如何找出这些错误。我的应用程序崩溃了 6 次(来自应用程序分析的报告)?【英文标题】:How to find out these errors. My app crashed 6 times (Report from app analytics)? 【发布时间】:2017-06-29 11:10:47 【问题描述】:这些错误是什么以及如何找出这些错误。在我的应用程序中,我使用 GoogleAnalytics、Fabric、Mix 面板、Core Data,我正在向服务器发送参数并从服务器获取数据。
这是我的代码:
- (IBAction)searchButton:(id)sender
if (sender == self.searchButton)
Reachability *networkReachability = [Reachability reachabilityForInternetConnection];
NetworkStatus networkStatus = [networkReachability currentReachabilityStatus];
if (networkStatus == NotReachable)
UIAlertController * alert = [UIAlertController alertControllerWithTitle : @"Message"
message : @"No Internet!Please Connect and try again."
preferredStyle : UIAlertControllerStyleAlert];
UIAlertAction * ok = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
];
[alert addAction:ok];
dispatch_async(dispatch_get_main_queue(), ^
[self presentViewController:alert animated:YES completion:nil];
);
// NSLog(@"There IS NO internet connection");
else
if ([self.selectOptionButton.currentTitle isEqualToString:@"Select Your Option"])
UIAlertController * alert = [UIAlertController alertControllerWithTitle : @"Message"
message : @"Please select option."
preferredStyle : UIAlertControllerStyleAlert];
UIAlertAction * ok = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
else if ([self.textField.text isEqualToString:@""])
UIAlertController * alert = [UIAlertController alertControllerWithTitle : @"Message"
message : @"Please enter number."
preferredStyle : UIAlertControllerStyleAlert];
UIAlertAction * ok = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
else
NSString * key1 = @"Something";
NSString * key2 = @"Something";
NSString * key3;
if ([self.optionButton.currentTitle isEqualToString:@"No0"])
key3 = @"0";
else if ([self.optionButton.currentTitle isEqualToString:@"No1"])
key3 = @"1";
else if ([self.optionButton.currentTitle isEqualToString:@"No2"])
key3 = @"2";
else if ([self.optionButton.currentTitle isEqualToString:@"No3"])
key3 = @"3";
else if ([self.optionButton.currentTitle isEqualToString:@"No4"])
key3 = @"4";
NSString * str;
NSArray * arr = [NSArray arrayWithObjects:self.key4, key1, key2, self.textField.text, key3, self.systemDateTime, self.key5, self.key6, nil];
str = [arr componentsJoinedByString:@"~"];
self.tempURLString = [[NSString alloc] initWithFormat:@"http://hostname/%@.php?da=%@", self.string, str];
//Getting data from server through JSON approach ...
self.urlSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
self.urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:self.tempURLString]];
self.dataTask = [self.urlSession dataTaskWithRequest:self.urlRequest completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)
NSMutableDictionary *serverRes = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
self.integer = [[serverRes objectForKey:@"str"] count];
if (!(error == nil))
UIAlertController * alert = [UIAlertController alertControllerWithTitle : [error localizedDescription]
message : [error localizedRecoverySuggestion]
preferredStyle : UIAlertControllerStyleAlert];
UIAlertAction * ok = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
];
[alert addAction:ok];
dispatch_async(dispatch_get_main_queue(), ^
[self presentViewController:alert animated:YES completion:nil];
);
// NSLog(@"%@", error);
else
if (serverRes == nil || self.integer == 0)
UIAlertController * alert = [UIAlertController alertControllerWithTitle : @"Message"
message : @"Please enter valid number."
preferredStyle : UIAlertControllerStyleAlert];
UIAlertAction * ok = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
];
[alert addAction:ok];
dispatch_async(dispatch_get_main_queue(), ^
[self presentViewController:alert animated:YES completion:nil];
);
// NSLog(@"Data Nil.....");
else
[self.array1 removeAllObjects];
[self.array2 removeAllObjects];
[self.array3 removeAllObjects];
[self.array4 removeAllObjects];
[self.array5 removeAllObjects];
[self.array6 removeAllObjects];
[self.array7 removeAllObjects];
[self.array8 removeAllObjects];
[self.array9 removeAllObjects];
[self.array10 removeAllObjects];
for (int i=0; i<self.integer; i++)
[self.array1 addObject:[[[serverRes objectForKey:@"str"] objectAtIndex:i] objectForKey:@"str1"]];
[self.array2 addObject:[[[serverRes objectForKey:@"sStr"] objectAtIndex:i] objectForKey:@"str2"]];
[self.array3 addObject:[[[serverRes objectForKey:@"sStr"] objectAtIndex:i] objectForKey:@"str3"]];
[self.array4 addObject:[[[serverRes objectForKey:@"str"] objectAtIndex:i] objectForKey:@"str4"]];
[self.array5 addObject:[[[serverRes objectForKey:@"str"] objectAtIndex:i] objectForKey:@"str5"]];
[self.array6 addObject:[[[serverRes objectForKey:@"str"] objectAtIndex:i] objectForKey:@"str6"]];
[self.array7 addObject:[[[serverRes objectForKey:@"str"] objectAtIndex:i] objectForKey:@"str7"]];
[self.array8 addObject:[[[serverRes objectForKey:@"str"] objectAtIndex:i] objectForKey:@"str8"]];
[self.array9 addObject:[[[serverRes objectForKey:@"str"] objectAtIndex:i] objectForKey:@"str9"]];
[self.array10 addObject:[[[serverRes objectForKey:@"str"] objectAtIndex:i] objectForKey:@"str10"]];
//Reload tableView Data...
dispatch_async(dispatch_get_main_queue(), ^
[self.tableView reloadData];
);
];
[self.dataTask resume];
错误是...
这些错误的确切含义是什么以及如何解决这些错误?
【问题讨论】:
【参考方案1】:您可以创建断点来定位错误行。
【讨论】:
以上是关于如何找出这些错误。我的应用程序崩溃了 6 次(来自应用程序分析的报告)?的主要内容,如果未能解决你的问题,请参考以下文章
使用 Sentry 时如何避免来自第三方扩展的不必要的崩溃报告?