如何将fedate分配给datepicker

时间:2015-07-27 19:10:04

标签: ios xcode swift datepicker nsexception

我正在尝试创建一个应用。我需要每天在用户决定使用日期选择器时发送通知,以便用户决定何时收到通知。我也找到了重复它的方法,但现在我无法将日期选择器分配到开火日期。请快速回答。 代码:

import UIKit

class TechByteSchedulingViewController: UIViewController {
   @IBOutlet weak var datePicker: UIDatePicker!

   @IBAction func SavePressed(sender: UIButton) {
       func sendNotification(sender: UIButton) {
           var localNotification = UILocalNotification()
           localNotification.fireDate = datePicker.date
           localNotification.repeatInterval = .CalendarUnitDay
           localNotification.alertBody = "check out your daily byte"
           localNotification.timeZone = NSTimeZone.defaultTimeZone()
           localNotification.applicationIconBadgeNumber = UIApplication.sharedApplication().applicationIconBadgeNumber + 1
           localNotification.soundName = UILocalNotificationDefaultSoundName

           UIApplication.sharedApplication().scheduleLocalNotification(localNotification)
    }

    func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {
        application.applicationIconBadgeNumber = 0
    }

}

以下是app delegate的代码 class AppDelegate:UIResponder,UIApplicationDelegate在我设置日期选择器后按完成时突出显示

导入UIKit

@UIApplicationMain class AppDelegate:UIResponder,UIApplicationDelegate {

var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    if(UIApplication.instancesRespondToSelector(Selector("registerUserNotificationSettings:"))) {

    application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: .Alert | .Badge | .Sound, categories: nil))
    var notification = UILocalNotification()
            // play default sound
    }

    // Override point for customization after application launch.

返回true     }

以下是控制台中的错误 2015-07-27 15:04:20.723每日字节[3058:170905]无法加载"秒#34;从标识符" NikhilKanamarlaDaily-Byte"中的nib引用的图像。 2015-07-27 15:04:20.723每日字节[3058:170905] CUICatalog:提供的资产名称无效:( null) 2015-07-27 15:04:20.723每日字节[3058:170905] CUICatalog:提供的资产名称无效:( null) 2015-07-27 15:04:20.724每日字节[3058:170905]无法加载"(null)"从标识符" NikhilKanamarlaDaily-Byte"中的nib引用的图像。 2015-07-27 15:04:20.729每日字节[3058:170905] CUICatalog:提供的资产名称无效:( null) 2015-07-27 15:04:20.729每日字节[3058:170905] CUICatalog:提供的资产名称无效:( null) 2015-07-27 15:04:20.729每日字节[3058:170905]无法加载"(null)"从标识符" NikhilKanamarlaDaily-Byte"中的nib引用的图像。 2015-07-27 15:04:20.729每日字节[3058:170905] CUICatalog:提供的资产名称无效:( null) 2015-07-27 15:04:20.729每日字节[3058:170905] CUICatalog:提供的资产名称无效:( null) 2015-07-27 15:04:20.729每日字节[3058:170905]无法加载"(null)"从标识符" NikhilKanamarlaDaily-Byte"中的nib引用的图像。 2015-07-27 15:04:27.565每日字节[3058:170905] - [Daily_Byte.TechByteSchedulingViewController DateChosen:]:无法识别的选择器发送到实例0x7fbd2a4bbef0 2015-07-27 15:04:27.589每日字节[3058:170905] *由于未捕获的异常终止应用程序' NSInvalidArgumentException',原因:' - [Daily_Byte.TechByteSchedulingViewController DateChosen:] :无法识别的选择器发送到实例0x7fbd2a4bbef0' * 第一次抛出调用堆栈: (     0 CoreFoundation 0x0000000100ba7c65 exceptionPreprocess + 165     1 libobjc.A.dylib 0x0000000102712bb7 objc_exception_throw + 45     2 CoreFoundation 0x0000000100baf0ad - [NSObject(NSObject)doesNotRecognizeSelector:] + 205     3 CoreFoundation 0x0000000100b0513c ___ forwarding _ + 988     4 CoreFoundation 0x0000000100b04cd8 _CF_forwarding_prep_0 + 120     5 UIKit 0x0000000101447d62 - [UIApplication sendAction:to:from:forEvent:] + 75     6 UIKit 0x000000010155950a - [UIControl _sendActionsForEvents:withEvent:] + 467     7 UIKit 0x00000001015588d9 - [UIControl touchesEnded:withEvent:] + 522     8 UIKit 0x0000000101494958 - [UIWindow _sendTouchesForEvent:] + 735     9 UIKit 0x0000000101495282 - [UIWindow sendEvent:] + 682     10 UIKit 0x000000010145b541 - [UIApplication sendEvent:] + 246     11 UIKit 0x0000000101468cdc _UIApplicationHandleEventFromQueueEvent + 18265     12 UIKit 0x000000010144359c _UIApplicationHandleEventQueue + 2066     13 CoreFoundation 0x0000000100adb431 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17     14 CoreFoundation 0x0000000100ad12fd __CFRunLoopDoSources0 + 269     15 CoreFoundation 0x0000000100ad0934 __CFRunLoopRun + 868     16 CoreFoundation 0x0000000100ad0366 CFRunLoopRunSpecific + 470     17 GraphicsServices 0x0000000104b7ba3e GSEventRunModal + 161     18 UIKit 0x00000001014468c0 UIApplicationMain + 1282     19每日字节0x000000010098cbf7 main + 135     20 libdyld.dylib 0x0000000102e48145 start + 1     21 ??? 0x0000000000000001 0x0 + 1 ) libc ++ abi.dylib:以NSException类型的未捕获异常终止 (lldb)

0 个答案:

没有答案