iOS 8中Swift的过期后时间?
用户可以在某个位置的地图上发布pin码,但当前一旦发布pin码,它将在地图上永久设置为用户发布。我想在这些帖子上设置一个过期时间,这样24小时后帖子就会被删除。我不确定这是解析还是只是Xcode的一部分 这里是我添加PIN的地方: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
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小时。然后查询当前时间