views:

35

answers:

2

I want to drop a bunch of pins for hotels on a map. I have a MKAnnotation class, and a view (MKAnnotationView) and I also have a class Hotel which has all information about the hotel

In terms of design how should these two work together. Should I have 2 classes or should I just combine both into a single class that inherits from MKAnnotationView and implements MKAnnotation protocol?

Because when I drop a pin I need to have all the details about the pin at hand if you know what I mean

A: 

You shouldn't mix model and view so the hotel and the annotation view should be separate classes. But I see no reason why the hotel class should not directly conform to the MKAnnotation protocol. Why did you separate this into another class?

Ole Begemann
Tks I will do that.
TheLearner
A: 

I agree with Ole. I use NSManagedObjects that conform to the MKAnnotation protocol (coordinate, title, subtitle, even region). That way I can effectively pass those around and maintain all the relevant information. I haven't figured out the best way to do this with MKPolylines or Polygons, however.

Greg Combs