这是我想要一直运行的示例代码服务
internal func backService()
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), { () -> Void in
let anObject = try! Realm().objects(remindertbl).filter("status = 0")
print("here")
for loop in anObject
{
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "dd/MM/yyyy hh:mm a"
let timestamp = dateFormatter.stringFromDate(NSDate())
let timeStampint = dateFormatter.dateFromString(timestamp)!.timeIntervalSince1970
if(loop.reminderdays == Int64(timeStampint))
{
if(loop.status == 0){
let notification = UILocalNotification()
notification.fireDate = NSDate(timeIntervalSince1970: 0)
notification.alertBody = "\(loop.title)"
notification.alertAction = "swipe to opem VLB Cloud!"
notification.soundName = UILocalNotificationDefaultSoundName
notification.userInfo = ["CustomField1": "w00t"]
UIApplication.sharedApplication().scheduleLocalNotification(notification)
let updateObject = try! Realm().objects(remindertbl).filter("status …Run Code Online (Sandbox Code Playgroud)