我在Xcode 8.3中为iOS应用程序提供了以下App委托:
<form class="navbar-form navbar-left" style="padding:0px; border-top-width:0px;"></form>
当我在模拟器或设备上启动应用程序时,它会崩溃,并显示以下消息:
void Home()
{
cout << "\nYou are in the living room of your rented home. Everything looks nice and tidy." << endl;
cout << "Choices:" << endl;
cout << "Sleep" << endl;
cout << "Leave" << endl;
cout << "Stats" << endl;
cin >> choice;
if (choice == "Sleep" || "sleep")
{
Sleep(); // No matter what choice I make, it always
//goes to the Sleep(); void.
}
if (choice == "Leave" || choice == "leave"){
TownSquare();
} if (choice == "Stats" || choice == "stats") {
StatsH();
}
else {
cout << "Please choose correctly!" << endl;
Home();
}
}
在模拟器中,这是一个略有不同的错误消息:
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
}
}
删除2017-07-04 21:26:04.284336+0200 MyApp[352:25788] -[NSTaggedPointerString containsObject:]: unrecognized selector sent to instance 0xa00000070696f764
2017-07-04 21:26:04.284569+0200 MyApp[352:25788] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [NSTaggedPointerString containsObject:]: unrecognized selector sent to instance 0xa00000070696f764'
*** First throw call stack:
(0x188baefe0 0x187610538 0x188bb5ef4 0x188bb2f54 0x188aaed4c 0x18ef7d030 0x18ef630f4 0x18ef77d18 0x18ef60474 0x18a757884 0x18a7576f0 0x18a757aa0 0x188b5d42c 0x188b5cd9c 0x188b5a9a8 0x188a8ada4 0x18ed4a384 0x18ed45058 0x100106fc8 0x187a9959c)
libc++abi.dylib: terminating with uncaught exception of type NSException
方法会导致崩溃消失。
有没有人知道发生了什么?
答案 0 :(得分:0)
您可能有第三方框架导致此问题。首先,您发布了Swift代码,但是收到了Objective-C错误消息。您正在使用的库可能正在注册处理通知。
其次,didReceiveRemoteNotification
需要在退出前始终将其称为completionHandler
。因此,空白函数会导致问题。
您需要使用completionHandler
,.newData
或.noData
参数调用.failed
,具体取决于您的搜索结果。
答案 1 :(得分:0)
找出问题:我的Info.plist
有背景模式&#39;设置为字符串而不是模式数组。修复可以修复崩溃。