I have a map setup to show an annotation with this code:
var newAnnotation = MKPointAnnotation()
if newPostJustPosted {
var newPostCoordinate = CLLocationCoordinate2DMake(userPosts.last!.postLatitude, userPosts.last!.postLongitude)
newAnnotation.coordinate = newPostCoordinate
newAnnotation.title = userPosts.last!.postTitle
mainMapView.addAnnotation(newAnnotation)
newPostJustPosted = false
println("New post was just posted")
}
This runs no problem, and the annotation shows up. After this, I tried to place an array of annotations via this code:
if userPosts.count > 0 {
for eachPost in 0...userPosts.count - 1 {
var currentPost = userPosts[eachPost]
newAnnotation.coordinate = CLLocationCoordinate2DMake(currentPost.postLatitude, currentPost.postLongitude)
println("Latitude is: " + "\(currentPost.postLatitude)")
newAnnotation.title = currentPost.postTitle
mainMapView.addAnnotation(newAnnotation)
println("This Ran")
}
}
According to the console, the Latitude and Longitude are correct, and the code is running the correct number of times, but no annotations show up on the map. I've now spent hours looking over this code and if it's something simple I'm going to feel so dumb. Either way, any help would be appreciated! Thanks!