Unable to place annotation without object release error


#1

I am able to build and run it, but as soon as I try to add the annotation, I get an error in xcode about an object release.

My ViewController.h

#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>


@interface ViewController : UIViewController <CLLocationManagerDelegate, MKMapViewDelegate, UITextFieldDelegate>

{
    CLLocationManager *locationManager;
    
    IBOutlet MKMapView *worldView;
    IBOutlet UIActivityIndicatorView *activityIndicator;
    IBOutlet UITextField *locationTitleField;
}

-(void) findLocation;
-(void) foundLocation: (CLLocation *)loc;

@end

My ViewController.m


#import "ViewController.h"
#import "BNRMapPoint.h"

@interface ViewController ()

@end

@implementation ViewController


-(void) findLocation
{
    [locationManager startUpdatingLocation];
    [activityIndicator startAnimating];
    [locationTitleField setHidden:YES];
    
}


-(void) foundLocation: (CLLocation *)loc;
{
    CLLocationCoordinate2D coord = [loc coordinate];
    
    BNRMapPoint *mp = [[BNRMapPoint alloc]initWithCoordinate:coord title:[locationTitleField text]];
    
    [worldView addAnnotation:mp];
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(coord, 250, 250);
    [worldView setRegion:region animated:YES];
    
    [locationTitleField setText:@""];
    [activityIndicator stopAnimating];
    [locationTitleField setHidden:NO];
    [locationManager stopUpdatingLocation];
}

-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    
    if (self)
    {
        locationManager = [[CLLocationManager alloc]init];
        
        [locationManager setDelegate:self];
        
        [locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
                
        [locationManager setDistanceFilter:50.0];

        
    }
    
    return self;
}


-   (void)viewDidLoad
{
    [worldView setShowsUserLocation:YES];
}


-   (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
    CLLocationCoordinate2D loc = [userLocation coordinate];
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(loc, 250, 250);
    [worldView setRegion:region animated:YES];
}



-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{ //CLLocationManagerDelegate method implementation
    
    
    //    NSTimeInterval t0=[[locations lastObject] timeIntervalSinceNow];
    
    NSLog(@"%@",(CLLocation *)[locations lastObject]);
    NSTimeInterval t= [[(CLLocation *)[locations lastObject] timestamp] timeIntervalSinceNow];
    
    if (t<-180) {
        return;
    }
    
    [self foundLocation:[locations lastObject]];
    
}




-   (void)locationManager:(CLLocationManager *)manager
    didFailWithError:(NSError *)error
{
    NSLog(@"Could not find location: %@", error);
}




-   (void)dealloc
{
    [locationManager setDelegate:nil];
}



-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [self findLocation];
    
    [textField resignFirstResponder];
    
    return YES;
}


@end

My BNRMapPoint.h


#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>

@interface BNRMapPoint : NSObject <MKAnnotation>

{
    
}
//a newly designated initializer for instances of BNRMapPoint

-(id)initWithCoordinate: (CLLocationCoordinate2D)c title:(NSString *)t;


//Required property for MKAnnotation
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;

//optional property for MKAnnotation
@property (nonatomic, copy) NSString *title;

@end

My BNRMapPoint.m


@implementation BNRMapPoint

@synthesize coordinate;

-(id)initWithCoordinate: (CLLocationCoordinate2D)c title:(NSString *)t
{
    self = [super init];
    if (self) {
        coordinate = c;
        [self setTitle:t];
    }
    return [self initWithCoordinate:CLLocationCoordinate2DMake(43.07, -89.32) title:@"Hometown"];
}


@end

Here is the error message I am getting:
libobjc.A.dylib`objc_release:
0x127a090: pushl %ebp
0x127a091: movl %esp, %ebp
0x127a093: subl 8, %esp [b]0x127a096: calll 0x127a09b ; objc_release + 11[/b] Thread 1: EXC_BAD_ACCESS (CODE=2, address=)xbf7ffffc) 0x127a09b: popl %ecx 0x127a09c: movl 8(%ebp), %eax 0x127a09f: testl %eax, %eax 0x127a0a1: je 0x127a0d5 ; objc_release + 69 0x127a0a3: movl (%eax), %edx 0x127a0a5: movl 16(%edx), %edx 0x127a0a8: andl -4, %edx
0x127a0ab: testb $2, 2(%edx)
0x127a0af: je 0x127a0c5 ; objc_release + 53
0x127a0b1: movl 1002149(%ecx), %ecx
0x127a0b7: movl %ecx, 4(%esp)
0x127a0bb: movl %eax, (%esp)
0x127a0be: calll 0x127908c ; objc_msgSend
0x127a0c3: jmp 0x127a0d5 ; objc_release + 69
0x127a0c5: movl %eax, (%esp)
0x127a0c8: movl $0, 4(%esp)
0x127a0d0: calll 0x127b9d0 ; -[NSObject release]
0x127a0d5: addl $8, %esp
0x127a0d8: popl %ebp
0x127a0d9: ret

Thanks for your help.