我的应用程序一直在启动时启动,我不知道为什么你们可以帮忙!该应用程序在模拟器中完美运行,但当我在设备上尝试时,应用程序在启动时崩溃,在我的项目中没有错误。
@implementation InboxViewController
- (void)viewDidLoad {
[super viewDidLoad];
PFUser *currentUser = [PFUser currentUser];
if ([PFUser currentUser]) {
// NSLog(@"current user: %@", currentUser.username);
} else {
[self performSegueWithIdentifier:@"showLogin" sender:self];
}
self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(retrieveMessages) forControlEvents:UIControlEventValueChanged];
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController.navigationBar setHidden:NO];
if ([PFUser currentUser]) {
[self retrieveMessages];
} else {
[self performSegueWithIdentifier:@"showLogin" sender:self];
}
}
retrieveMessage方法:
- (void)retrieveMessages
{
PFQuery *query = [PFQuery queryWithClassName:@"Messages"];
[query whereKey:@"recipientIds" equalTo:[[PFUser currentUser] objectId]];
[query orderByDescending:@"createdAt"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error){
if (error) {
NSLog(@"error %@ %@", error, [error userInfo]);
} else {
self.messages = objects;
[self.tableView reloadData];
}
if ([self.refreshControl isRefreshing]) {
[self.refreshControl endRefreshing];
}
}];
}
崩溃日志:
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 0
Last Exception Backtrace:
(0x1829c02d8 0x1945900e4 0x1829c0218 0x100103a80 0x100107f70 0x1001580bc 0x1000c95e4 0x1877e3364 0x1877e4650 0x188b6b594 0x182977a54 0x1829779b4 0x182975934 0x1828a12d4 0x18c1cf6fc 0x18749ef40 0x1000c9c28 0x194c3aa08)
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x0000000194d53270 0x194d38000 + 111216
1 libsystem_pthread.dylib 0x0000000194df116c 0x194dec000 + 20844
2 libsystem_c.dylib 0x0000000194ccab14 0x194c68000 + 404244
3 libc++abi.dylib 0x0000000193d5d414 0x193d5c000 + 5140
4 libc++abi.dylib 0x0000000193d7cb88 0x193d5c000 + 134024
5 libobjc.A.dylib 0x00000001945903bc 0x194588000 + 33724
6 libc++abi.dylib 0x0000000193d79bb0 0x193d5c000 + 121776
7 libc++abi.dylib 0x0000000193d79474 0x193d5c000 + 119924
8 libobjc.A.dylib 0x0000000194590200 0x194588000 + 33280
9 CoreFoundation 0x00000001829c0214 0x182898000 + 1212948
14 UIKit 0x00000001877e3360 0x187428000 + 3912544
15 UIKit 0x00000001877e464c 0x187428000 + 3917388
16 AppSupport 0x0000000188b6b590 0x188b68000 + 13712
17 CoreFoundation 0x0000000182977a50 0x182898000 + 916048
18 CoreFoundation 0x00000001829779b0 0x182898000 + 915888
19 CoreFoundation 0x0000000182975930 0x182898000 + 907568
20 CoreFoundation 0x00000001828a12d0 0x182898000 + 37584
21 GraphicsServices 0x000000018c1cf6f8 0x18c1c4000 + 46840
22 UIKit 0x000000018749ef3c 0x187428000 +
24 libdyld.dylib 0x0000000194c3aa04 0x194c38000 + 10756
Thread 1 name: Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0 libsystem_kernel.dylib 0x0000000194d38c24 0x194d38000 + 3108
1 libdispatch.dylib 0x0000000194c1de6c 0x194c0c000 + 73324
2 libdispatch.dylib 0x0000000194c0f998 0x194c0c000 + 14744
Thread 2:
0 libsystem_kernel.dylib 0x0000000194d53c78 0x194d38000 + 113784
1 libsystem_pthread.dylib 0x0000000194ded2d8 0x194dec000 + 4824
2 libsystem_pthread.dylib 0x0000000194deceec 0x194dec000 + 3820
Thread 5 name: Dispatch queue: com.parse.reachability
Thread 4 name: Dispatch queue: com.parse.PFCommandCache.processing
Thread 7 name: Dispatch queue: com.parse.PFCommandCache.processing
Thread 11 name: Dispatch queue: NSOperationQueue 0x1740329a0 :: NSOperation 0x1740e8200 (QOS: LEGACY)
它持续一段时间可能是由于app delegate中的通知确实用选项方法完成启动:
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
可能是因为从解析中检索邮件会导致问题吗?查看崩溃日志中的最后几条线程消息?