Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8209689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:48:49+00:00 2026-06-07T09:48:49+00:00

Problem I am having a problem with my MKMapView.When I initialize it and try

  • 0

Problem

I am having a problem with my MKMapView.When I initialize it and try to add a couple annotations, the app crashes, giving my a SIGABRT and claiming that I have an “uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[__NSCFSet addObject:]: attempt to insert nil'” I have messed around with NSLogs and my code and found that it occurs whenever I call [mapView addAnnotation:myAnnotation]. I have tried both annotations individually and the app still crashes.

Code

Here is the code I am using for my MKMapView

IBOutlet MKMapView *mapView; //these are in interface
DisplayMap *thing1; //yes, I have @properties too, and I synthesize them
DisplayMap *thing2;

-(void) initMap //called in viewDidLoad after [super viewDidLoad]
{
[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
mapView.showsUserLocation = YES;
MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
region.center.latitude = 0;
region.center.longitude = 0;
region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;
[mapView setRegion:region animated:YES]; 
[mapView setDelegate:self];

thing1.title = @"thing1";
thing1.subtitle = @"is here"; 
thing1.coordinate = region.center; 

thing2.title = @"thing2";
thing2.subtitle = @"is somewhere"; 
CLLocationCoordinate2D thing2Coord = {0.005,0.005};
thing2.coordinate = thing2Coord;
[mapView addAnnotation:thing1];
[mapView addAnnotation:thing2];
}

//and my DisplayMap code
//the .h
#import <Foundation/Foundation.h>
#import <MapKit/MKAnnotation.h>

@interface DisplayMap : NSObject <MKAnnotation> {
CLLocationCoordinate2D coordinate; 
NSString *title; 
NSString *subtitle;
}

@property (nonatomic, assign) CLLocationCoordinate2D coordinate; 
@property (nonatomic, copy) NSString *title; 
@property (nonatomic, copy) NSString *subtitle;

@end
//the .m
#import "DisplayMap.h"

@implementation DisplayMap
@synthesize coordinate,title,subtitle;

-(void)dealloc{
[title release];
[subtitle release];
[super dealloc];
}

@end

Theories

I tried to isolate initMap so that it is called before any of the rest of my app loads. I have other processes running later, but they should not be active at this point because they have not been initialized yet. I imagine the problem could have something to do with my initialization of the MKMapView itself, or in my Displaymap properties. Xcode can’t detect it, whatever it is, and I’m not really sure what the error I’m getting even means.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:48:52+00:00Added an answer on June 7, 2026 at 9:48 am

    From your code, it doesn’t look like you are ever instantiating thing1 and thing2.

    Try adding these lines at the beginning of your init function.

     thing1 = [[DisplayMap alloc] init]; 
     thing2 = [[DisplayMap alloc] init];
    

    Just because these members are properties doesn’t mean that they are auto-initialized.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some problem with MKMapView / annotations / UINavigationController. Basically, i manage my
I have this problem having to display my jasper report on my grails application.
Im having problem in my UIscrollView ,this is what I have done: Whenever a
I'm having problem with datagrid view. I have attached an image with the code
m having problem in passing parameter to controller action, i have done the following
[Problem] Having created a shared library that is to be deployed on a server
having problem with null pointer exception and i read few article bout that error
Having this problem with my android app I struggled with this for some time
i have that problem, I actualice the positions of the items of mi googlemap
I am working on an MKMapView based iPhone / iPad mapping app that overlays

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.