Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMcIvor Steiner
9,971 PointsHow to just pass the businesses to the 'addAnnotations' method?
In this video, you ran into an issue where it was not working if you just passed the businesses to the addAnnotations
method on the map. The business object does conform to the MKAnnotation
protocol, so this should work, and would be a lot simpler than the solution that was used in the video. Has anyone determined how to make the first approach work?
2 Answers
Sarah Hurtgen
Treehouse Project ReviewerIn the video he accidentally typed longitude instead of latitude in the YelpBusiness extension, if you follow exactly what he typed, it won't work - but if you follow what he says, it should work fine!
// his original line
var coordinate: CLLocationCoordinate2D {
return CLLocationCoordinate2D(latitude: location.longitude, longitude: location.longitude)
}
// how it should read
var coordinate: CLLocationCoordinate2D {
return CLLocationCoordinate2D(latitude: location.latitude, longitude: location.longitude)
}
Nathan F.
30,773 PointsI wondered what his error was because it worked perfectly fine for me. That makes sense! Haha
Scott Baumbich
Courses Plus Student 22,129 PointsDon't make the same mistake as I did when adding the annotations.
Apple as 2 methods defined. One has an "s" (annotations) accept an array of MKAnnotations And the other is not an arrays
open func addAnnotation(_ annotation: MKAnnotation)
open func addAnnotations(_ annotations: [MKAnnotation])
Angus Muller
iOS Development Techdegree Graduate 12,473 PointsAngus Muller
iOS Development Techdegree Graduate 12,473 PointsFor me it worked straight away with the first way of doing it (addAnnotation method) without having to implerment the second way that was shown , I don't know why it worked for me though?