title: MKAnnotation, simple example
body: <p>Is there a simple example project for <code>MKAnnotation</code>? I don't know what to pass at "<code>addAnnotation</code>", as it wants some "<code>id&lt;Annotation&gt;</code>".
  The examples at the developer site are all with arrays or parsers or so, I just need a very easy example to first understand, how the whole thing works.</p>
  
  <p>Thanks in advance..</p>
  
  <p>EDIT:</p>
  
  <p>I set up a class <code>Pin</code>. In the .h it writes</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  #import &lt;MapKit/MapKit.h&gt;
  
  @interface Pin : NSObject &lt;MKAnnotation&gt; {
  CLLocationCoordinate2D coordinate;
  NSString *title;
  NSString *subTitle;
  }
  
  @property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
  @property (nonatomic, readonly) NSString *title;
  @property (nonatomic, readonly) NSString *subTitle;
  
  - (id)initWithCoordinates:(CLLocationCoordinate2D)location placeName:(NSString *)placeName description:(NSString *)description;
  @end
  </code></pre>
  
  <p>according to what onnoweb answered.</p>
  
  <p>In the Pin.m, I implemented like this, according to different examples:</p>
  
  <pre><code>#import "Pin.h"
  
  @implementation Pin
  
  @synthesize title, subTitle;
  
  - (CLLocationCoordinate2D) coordinate {
  CLLocationCoordinate2D coords;
  coords.latitude = coordinate.latitude; //i want it that way
  coords.longitude =  7.1352260; //this way it works
  
  return coords;
  
  - (NSString *) title {
  return @"Thats the title";
  }
  
  - (NSString *) subtitle {
  return @"Thats the sub";
  }
  
  - (id)initWithCoordinates:(CLLocationCoordinate2D)location placeName:(NSString *)placeName description:(NSString *)description {
  
  return self;
  }
  
  - (void) dealloc {
  [super dealloc];
  }
  
  @end
  </code></pre>
  
  <p>So if I set the coordinates by hand, as pointed in the comment, it works. But I'd like to be able to set the value dynamically like in the first comment. I tried various ways, but none worked out. As you don't specify a <code>- (CLLocationCoordinate2D) coordinate</code> I tried to just synthesize <code>coordinate</code>, but like that it won't work either.</p>
  
  <p>Could you show me your <strong>MapPin.m</strong>? </p>
  
  <p>EDIT 2:</p>
  
  <p>I set <code>mapCenter</code> like</p>
  
  <pre><code>- (void)viewWillAppear:(BOOL)animated {
  self.locationManager = [[CLLocationManager alloc] init];
  self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
  self.locationManager.delegate = self;
  [self.locationManager startUpdatingLocation];
  
  CLLocation *curPos = locationManager.location;
  location = curPos.coordinate;
  
  CLLocationCoordinate2D mapCenter;
  mapCenter.latitude =  location.latitude;
  mapCenter.longitude = location.longitude;
  
  MKCoordinateSpan mapSpan;
  mapSpan.latitudeDelta = 0.005;
  mapSpan.longitudeDelta = 0.005;
  
  MKCoordinateRegion mapRegion;
  mapRegion.center = mapCenter;
  mapRegion.span = mapSpan;
  
  mapKitView.region = mapRegion;
  mapKitView.mapType = MKMapTypeStandard;
  mapKitView.showsUserLocation=TRUE;
  }
  </code></pre>
  
  <p>Anything wrong with that?</p>