Note that there are some explanatory texts on larger screens.

plurals
  1. POGettin Bad Access while adding Annotations
    primarykey
    data
    text
    <p>I´m trying to to add many Annotations (depends on how many objects a have in my Array) to my Mapview like this:</p> <pre><code>-(void)viewWillAppear:(BOOL)animated { [mapView removeAnnotations:mapView.annotations]; for (Daten *info in datenArray) { CLLocationCoordinate2D location; location.latitude = (double)[info.lati doubleValue]; location.longitude = (double)[info.longi doubleValue]; MapPin *newAnnotation =[[[MapPin alloc] initWithTitle:info.rating andCoordinate:location] autorelease]; [mapView addAnnotation:newAnnotation]; } [self zoomToFitMapAnnotations:self.mapView]; [self.mapView selectAnnotation:self.mapView.annotations.lastObject animated:YES]; </code></pre> <p>}</p> <p>The first time I switch to that View it works perfectly...But if i come a second time to this View, i get this Bad Access with Error:</p> <pre><code>*** -[CFString length]: message sent to deallocated instance 0x17e140c0 </code></pre> <p>Edit:</p> <p>Thats my MapPin Class:</p> <pre><code>@interface MapPin : NSObject &lt;MKAnnotation&gt; { NSString *title; NSString *subtitle; CLLocationCoordinate2D coordinate; } @property (nonatomic, copy) NSString *title; @property (nonatomic, readonly) CLLocationCoordinate2D coordinate; @property (nonatomic, readonly, copy) NSString *subtitle; - (id)initWithTitle:(NSString *)ttl andCoordinate:(CLLocationCoordinate2D)c2d; </code></pre> <p>EDIT2:</p> <p><img src="https://i.stack.imgur.com/M5ppc.png" alt="Exception"></p> <p>Edit3:</p> <p>Here´s the implementation:</p> <pre><code>#import "MapPin.h" @implementation MapPin @synthesize title, coordinate, subtitle; - (id)initWithTitle:(NSString *)ttl andCoordinate:(CLLocationCoordinate2D)c2d { [super init]; subtitle = ttl; title = @"Rating:"; coordinate = c2d; return self; } - (void)dealloc { [title release]; [subtitle release]; [super dealloc]; } @end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload