ios - Adding timestamp to MapView Annotation via Parse? -


this current query setup retrieve data parse , set annotation pin on mapview. take time created , add simple 5:00pm example within annotation well. there way pull time , not date parse through query , set mkannotation?

override func viewdidappear(animated: bool) { 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 {         // find succeeded.         println("successful query annotations")         // found objects          let myposts = points as! [pfobject]          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!             annotation.subtitle = post["username"] as! string!               self.mapview.addannotation(annotation)         }      } else {         // log details of failure         println("error: \(error)")     } } 

here photo of parse backend give better idea:

http://i1249.photobucket.com/albums/hh512/zachkhan3/screen%20shot%202015-04-24%20at%205.39.18%20pm.png

pfobject has "createdat" property. assign nsdate object , need format using nsdateformatter display time component only. untested code you.

       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!         annotation.subtitle = post["username"] as! string!         let formatter = nsdateformatter()         formatter.datestyle = nsdateformatterstyle.nostyle         formatter.timestyle = .shortstyle          let datestring = formatter.stringfromdate(post.createdat)         annotation.timetitle /* or equivalent */ = datestring          self.mapview.addannotation(annotation)     } 

Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -