简体   繁体   English

如何在Swift中的AppDelegate中初始化NSTimer

[英]How to initialize an NSTimer in the AppDelegate in Swift

Is there a way to initialize an NSTimer in swift in the AppDelegate . 有没有一种方法可以在AppDelegate中快速初始化NSTimer I'm trying to start a timer once a user exit's a beacon monitoring region like so. 我试图在用户退出这样的信标监视区域后启动计时器。

func locationManager(manager: CLLocationManager!,
    didExitRegion region: CLRegion!) {

        manager.stopRangingBeaconsInRegion(region as! CLBeaconRegion)
        manager.stopUpdatingLocation()

        NSLog("You exited the region")
        sendLocalNotificationWithMessage("You exited the region", playSound: true)
}

var timer = NSTimer.scheduledTimerWithTimeInterval(0.4, target: self, selector: Selector("yourFunction"), userInfo: nil, repeats: true)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM