无法转换类型' __ NSCFString'到了NSDate' ,NSUserDefaults

时间:2015-09-17 13:53:03

标签: ios iphone swift nsuserdefaults

您好我试图从NSUSerDefault获取日期,当我尝试将AnyObject强制转换为NSDate时,我收到此错误:

Could not cast value of type '__NSCFString' (0x101d6bef0) to 'NSDate' 

这是完整的代码:

if let some = brain.defaults.objectForKey("Today")  {

        let demoo = NSDate().secondsFrom(some as! NSDate)
        brain.numberCount = Float(demoo)
        brain.defaults.synchronize()
        brain.timer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: Selector("update"), userInfo: nil, repeats: true)
        startButtonUIButton.hidden = true
        brain.progressCircle.strokeEnd = CGFloat(demoo/86400)

    }
错误就在这条线上:

let demoo = NSDate().secondsFrom(some as! NSDate)

任何想法为什么?

0 个答案:

没有答案