Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.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 8中Swift的过期后时间?_Ios_Xcode_Swift_Mapkit - Fatal编程技术网

iOS 8中Swift的过期后时间?

iOS 8中Swift的过期后时间?,ios,xcode,swift,mapkit,Ios,Xcode,Swift,Mapkit,用户可以在某个位置的地图上发布pin码,但当前一旦发布pin码,它将在地图上永久设置为用户发布。我想在这些帖子上设置一个过期时间,这样24小时后帖子就会被删除。我不确定这是解析还是只是Xcode的一部分 这里是我添加PIN的地方: var annotationQuery = PFQuery(className: "Post") currentLoc = PFGeoPoint(location: MapViewLocationManager.location) //annotati

用户可以在某个位置的地图上发布pin码,但当前一旦发布pin码,它将在地图上永久设置为用户发布。我想在这些帖子上设置一个过期时间,这样24小时后帖子就会被删除。我不确定这是解析还是只是Xcode的一部分

这里是我添加PIN的地方:

var annotationQuery = PFQuery(className: "Post")
    currentLoc = PFGeoPoint(location: MapViewLocationManager.location)
    //annotationQuery.whereKey("Location", nearGeoPoint: currentLoc, withinMiles: 10)
    annotationQuery.whereKeyExists("Location")
    annotationQuery.findObjectsInBackgroundWithBlock {
        (points, error) -> Void in
        if error == nil {
            // The find succeeded.
            println("Successful query for annotations")
            // Do something with the found objects

            let myPosts = points as! [PFObject]

            for post in myPosts {
                let point = post["Location"] as! PFGeoPoint
                let annotation = MKPointAnnotation()
                annotation.coordinate = CLLocationCoordinate2DMake(point.latitude, point.longitude)
                annotation.title = post["title"] as! String!
                let annotationSubTitleUser = post["username"] as! String!

                let formatter = NSDateFormatter()
                formatter.dateStyle = NSDateFormatterStyle.ShortStyle
                formatter.timeStyle = .ShortStyle
                let dateString = formatter.stringFromDate(post.createdAt!)

                annotation.subtitle = "User: \(annotationSubTitleUser)  Time: \(dateString)"

                self.mapView.addAnnotation(annotation)
            }

        } else {
            // Log details of the failure
            println("Error: \(error)")
        }
    }

提前感谢您的帮助

If是一个解析的东西。在解析时将到期日添加为数据库条目,每次创建pin时,将到期日添加为当前时间+24小时。然后查询当前时间expirationdate。您提供的代码用于选择pins,您需要首先将过期添加到数据库中。为简单起见,我会说将过期日期添加为int,并使用1970年以来的历元时间秒;检查然后再加上currentEpochSeconds+24*60*60我对如何实现这个方法有点困惑。你有一些示例代码让我能更好地理解吗?