Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 应用程序运行时带有一个";println";方法,但当它';删除_Ios_Swift_Exc Bad Access - Fatal编程技术网

Ios 应用程序运行时带有一个";println";方法,但当它';删除

Ios 应用程序运行时带有一个";println";方法,但当它';删除,ios,swift,exc-bad-access,Ios,Swift,Exc Bad Access,我有以下应用程序将进入前台方法代码,以及下一个println方法:println(“nextUpdate unwrapped”)。如果存在此打印,则应用程序运行时不会出现问题,只要我删除/注释掉此println方法,应用程序就会以EXC_BAD_ACCESS崩溃,但控制台中未指定错误的位置,因此我不知道是什么导致我的应用程序崩溃 func applicationWillEnterForeground(application: UIApplication!) { // Called as

我有以下
应用程序将进入前台
方法代码,以及下一个println方法:
println(“nextUpdate unwrapped”)
。如果存在此打印,则应用程序运行时不会出现问题,只要我删除/注释掉此println方法,应用程序就会以EXC_BAD_ACCESS崩溃,但控制台中未指定错误的位置,因此我不知道是什么导致我的应用程序崩溃

func applicationWillEnterForeground(application: UIApplication!) {
    // Called as part of the transition from the background to the
    // inactive state; here you can undo many of the changes made on
    // entering the background.

    countForWill++
    var timeIntervalSince1970: NSTimeInterval!
    Logger.printLogToConsole(TAG, aMethodName: __FUNCTION__, aMessage: "Runs for the \(countForWill) time")

    var lastUpdateTimeStamp: AnyObject? = NSUserDefaults.standardUserDefaults().doubleForKey(KiboConstants.UserDefaultsStrings.USER_DEF_LAST_UPDATE_TIME_STAMP)
    var nextUpdate: AnyObject? = NSUserDefaults.standardUserDefaults().doubleForKey(KiboConstants.UserDefaultsStrings.USER_DEF_NEXT_UPDATE)
    if let lastUpdateTimeStampUnwrapped: AnyObject = lastUpdateTimeStamp {

        if let nextUpdateUnwrapped: AnyObject = nextUpdate {
            println("nextUpdate unwrapped")

            let lastUpdateTimeStampUnwrappedDouble: Double = lastUpdateTimeStampUnwrapped as Double
            var nextUpdateUnwrappedDouble: Double = nextUpdateUnwrapped as Double
            nextUpdateUnwrappedDouble = nextUpdateUnwrappedDouble * 60

            //var nextUpdateTimeStamp: Double = (lastUpdateTimeStampUnwrapped as Double) + (nextUpdateUnwrapped as Double * 60)
            var nextUpdateTimeStamp: Double = lastUpdateTimeStampUnwrappedDouble + nextUpdateUnwrappedDouble
            timeIntervalSince1970 = NSDate().timeIntervalSince1970
            if (nextUpdateTimeStamp < timeIntervalSince1970) {
                checkForNewSources()
            } else {
                let updatedNextUpdate = nextUpdateTimeStamp - NSDate().timeIntervalSince1970
                setTimeWithNextUpdateValue(updatedNextUpdate)
            }
        } else {
            var nextUpdateTimeStamp: Double = (lastUpdateTimeStampUnwrapped as Double) + (DEFAULT_NEXT_UPDATE_VAL * 60)
            timeIntervalSince1970 = NSDate().timeIntervalSince1970
            if (nextUpdateTimeStamp < timeIntervalSince1970) {
                checkForNewSources()
            } else {
                let updatedNextUpdate = nextUpdateTimeStamp - timeIntervalSince1970
                setTimeWithNextUpdateValue(updatedNextUpdate)
            }
        }
    } else {
        checkForNewSources()
    }

    let topViewController = self.IndexNavigationController.topViewController
    if topViewController is HelloViewController {

        var found: Bool = false
        found = SystemUtils.CommonTasks.isKiboKeyboardEnabled()
        if found {
            let activateViewController = ActivateViewController()
            self.IndexNavigationController.pushViewController(activateViewController, animated: false)
        }
    }
}
func应用程序将进入前台(应用程序:UIApplication!){
//作为从背景到背景的过渡的一部分调用
//非活动状态;在此可以撤消对所做的许多更改
//进入背景。
伯爵意志++
var timeIntervalSince1970:NSTimeInterval!
Logger.printLogToConsole(标记,名称:函数,消息:“运行\(countForWill)时间”)
var lastUpdateTimeStamp:AnyObject?=NSUserDefaults.standardUserDefaults().doubleForKey(KiboConstants.UserDefaultsString.USER_DEF_LAST_UPDATE_TIME_STAMP)
var nextUpdate:AnyObject?=NSUserDefaults.standardUserDefaults().doubleForKey(KiboConstants.UserDefaultsString.USER\u下一次更新)
如果让lastUpdateTimeStampUnwrapped:AnyObject=lastUpdateTimeStamp{
如果让nextUpdateUnwrapped:AnyObject=nextUpdate{
println(“下一个打开的日期”)
让LastUpdateTimeStampUnwrappedouble:Double=lastUpdateTimeStampUnwrapped为Double
var nextupdateunwrappedouble:Double=nextUpdateUnwrapped为Double
nextUpdateUnwrappedouble=nextUpdateUnwrappedouble*60
//var nextUpdateTimeStamp:Double=(lastUpdateTimeStampUnwrapped为Double)+(nextUpdateUnwrapped为Double*60)
var nextUpdateTimeStamp:Double=LastUpdateTimeStampUnwrappedouble+nextUpdateUnwrappedouble
timeIntervalSince1970=NSDate()。timeIntervalSince1970
if(nextUpdateTimeStamp

现在,显然这是一个计时错误,但我刚刚开始为iOS开发,我不知道如何调试和修复这个问题

我确实明白了为什么你的应用程序会崩溃,但我看不出这与
println
语句之间有任何联系。如果您看不到应用程序崩溃的地方,请尝试从
println
行的正上方开始进行逐步调试?打开
NSZombieMode
也会有助于调试。