Users can post a pin on a map at a location, but currently once they post the pin it is set on the map forever as a user post. I would like to set a time expiration on these posts, so after 24 hours the post is wiped and gone. I'm not sure if this is a Parse thing or if its just part of Xcode?
here is where I add pins:
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)")
}
}
Thank you for the help in advance!