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 4591280
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:22:19+00:00 2026-05-21T22:22:19+00:00

when i click on an annotation, it suppose to show me that small window

  • 0

when i click on an annotation, it suppose to show me that small window which is not my case, the annotations are here but when i click on one the application throw an exception, and i thought that this code make problems :

  for (int i=0; i<[array count]; i++) {

           NSDictionary *stationEnCours=[array objectAtIndex:i];


           NSString *distance=[stationEnCours objectForKey:@"distance"];
           float lng = [[stationEnCours objectForKey:@"ssiphone_longitude"]   floatValue];
           float lat = [[stationEnCours objectForKey:@"ssiphone_latitude"] floatValue];
           NSString *ensStation=[stationEnCours objectForKey:@"ssiphone_enseigne"];

           location2D = (CLLocationCoordinate2D){ .latitude = lat, .longitude = lng };
           MyLocation *annotation=[[[MyLocation alloc]initWithName:ensStation distanceVersLaStation:distance coordinate:location2D]autorelease];
           [mapView addAnnotation:annotation];
           MKCoordinateSpan span={latitudeDelta:0.2,longitudeDelta:0.2};
           MKCoordinateRegion region={location2D,span};
           [mapView setRegion:region];
           [self.view addSubview:mapView];
           }

and for MyLocation class which implement the MKAnnotation protocol, i have this :

@implementation MyLocation
@synthesize enseigneDeLaStation=_enseigneDeLaStation;
@synthesize distanceVersLaStation=_distanceVersLaStation;
@synthesize coordinate=_coordinate;



-(id)initWithName:(NSString *)enseigneDeLaStation distanceVersLaStation:(NSString *) distanceVersLaStation coordinate:(CLLocationCoordinate2D)coordinate
{
    if ((self = [super init])) {
        _enseigneDeLaStation = [enseigneDeLaStation copy];
        _distanceVersLaStation = [distanceVersLaStation copy];
        _coordinate = coordinate;
    }
    return self;
}

- (NSString *)title {
    return _enseigneDeLaStation;
}

- (NSString *)subtitle {
    return _distanceVersLaStation;
}

- (void)dealloc
{
    [_enseigneDeLaStation release];
    _enseigneDeLaStation = nil;
    [_distanceVersLaStation release];
    _distanceVersLaStation = nil;    
    [super dealloc];
}       


@end

please help, thx in advance :))

EDIT
@Anna : i have fix the points that you mention, but i still have the same problem :

for (int i=0; i<[array count]; i++) {
           //afficher sur la carte (map)
           NSDictionary *stationEnCours=[array objectAtIndex:i];
           //NSString *adresseStation=[stationEnCours objectForKey:@"ssiphone_adresse"];

           //float distance = [[stationEnCours objectForKey:@"distance"] floatValue];
           NSString *distance=[stationEnCours objectForKey:@"distance"];
           NSLog(@"distance: %.1f",distance);
           float lng = [[stationEnCours objectForKey:@"ssiphone_longitude"] floatValue];
           float lat = [[stationEnCours objectForKey:@"ssiphone_latitude"] floatValue];
           NSString *ensStation=[stationEnCours objectForKey:@"ssiphone_enseigne"];

           //CLLocationCoordinate2D location2D= {.latitude = lat, .longitude = lng};
           location2D = (CLLocationCoordinate2D){ .latitude = lat, .longitude = lng };
           MyLocation *annotation=[[[MyLocation alloc]initWithName:ensStation distanceVersLaStation:distance coordinate:location2D]autorelease];
           [mapView addAnnotation:annotation];
          // MKCoordinateSpan span={latitudeDelta:0.2,longitudeDelta:0.2};
          // MKCoordinateRegion region={location2D,span};
           //[mapView setRegion:region];
           //[self.view addSubview:mapView];

           }
           MKCoordinateSpan span={latitudeDelta:0.2,longitudeDelta:0.2};
           MKCoordinateRegion region={location2D,span};
           [mapView setRegion:region];
           [self.view addSubview:mapView];

the Exception stack is :

2011-05-05 13:26:04.518[786:207] -[NSDecimalNumber stringByStandardizingWhitespace]: unrecognized selector sent to instance 0x6e6dca0
2011-05-05 13:26:04.520[786:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSDecimalNumber stringByStandardizingWhitespace]: unrecognized selector sent to instance 0x6e6dca0'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x02915919 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x0272a5de objc_exception_throw + 47
    2   CoreFoundation                      0x0291742b -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x02887116 ___forwarding___ + 966
    4   CoreFoundation                      0x02886cd2 _CF_forwarding_prep_0 + 50
    5   UIKit                               0x00451608 -[UICalloutView setSubtitle:animated:] + 88
    6   UIKit                               0x004512d8 -[UICalloutView setSubtitle:] + 49
    7   MapKit                              0x023849de -[MKAnnotationContainerView _showBubbleForAnnotationView:bounce:scrollToFit:userInitiated:avoid:] + 527
    8   MapKit                              0x02385735 -[MKAnnotationContainerView _setSelectedAnnotationView:bounce:pressed:scrollToFit:userInitiated:avoid:] + 651
    9   MapKit                              0x0237fb78 -[MKAnnotationContainerView _setSelectedAnnotationView:bounce:pressed:scrollToFit:userInitiated:] + 144
    10  MapKit                              0x0235a891 -[MKMapView handleTap:] + 459
    11  UIKit                               0x005a2394 -[UIGestureRecognizer _updateGestureWithEvent:] + 727
    12  UIKit                               0x0059ebf3 -[UIGestureRecognizer _delayedUpdateGesture] + 47
    13  UIKit                               0x005a3486 _UIGestureRecognizerUpdateObserver + 637
    14  CoreFoundation                      0x028f6d1b __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27
    15  CoreFoundation                      0x0288b987 __CFRunLoopDoObservers + 295
    16  CoreFoundation                      0x02854c17 __CFRunLoopRun + 1575
    17  CoreFoundation                      0x02854280 CFRunLoopRunSpecific + 208
    18  CoreFoundation                      0x028541a1 CFRunLoopRunInMode + 97
    19  GraphicsServices                    0x02e8e2c8 GSEventRunModal + 217
    20  GraphicsServices                    0x02e8e38d GSEventRun + 115
    21  UIKit                               0x0033ab58 UIApplicationMain + 1160
    22  myApp                         0x000021f8 main + 102
    23  myApp                          0x00002189 start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.
(gdb) 

EDIT 1 :

the two NSLogs :

NSLog(@"distance: %@", [distance class]);
           NSLog(@"ensStation: %@", [ensStation class]);

inside the for loop show me that :

2011-05-05 13:38:01.223 myApp[856:207] distance: NSCFNumber
2011-05-05 13:38:01.223 myApp[856:207] ensStation: NSCFString
2011-05-05 13:38:01.224 myApp[856:207] distance: NSDecimalNumber
2011-05-05 13:38:01.224 myApp[856:207] ensStation: NSCFString
2011-05-05 13:38:01.225 myApp[856:207] distance: NSDecimalNumber
2011-05-05 13:38:01.225 myApp[856:207] ensStation: NSCFString
2011-05-05 13:38:01.225 myApp[856:207] distance: NSDecimalNumber
2011-05-05 13:38:01.225 myApp[856:207] ensStation: NSCFString
2011-05-05 13:38:01.225 myApp[856:207] distance: NSDecimalNumber
2011-05-05 13:38:01.226 myApp[856:207] ensStation: NSCFString
2011-05-05 13:38:01.226 myApp[856:207] distance: NSCFNumber
2011-05-05 13:38:01.226 myApp[856:207] ensStation: NSCFString
2011-05-05 13:38:01.226 myApp[856:207] distance: NSDecimalNumber
2011-05-05 13:38:01.227 myApp[856:207] ensStation: NSCFString
2011-05-05 13:38:01.227 myApp[856:207] distance: NSDecimalNumber
2011-05-05 13:38:01.227 myApp[856:207] ensStation: NSCFString
(gdb) 

Edit 2 :
Hi again, the problem with the annotation is fixed but i think i got the the same exception when i quit and come back to the view :

2011-05-05 14:56:47.374 TopStation[1234:207] *** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x806b620> was mutated while being enumerated.(
    "<MyLocation: 0x806c910>",
    "<MyLocation: 0x806c7e0>",
    "<MyLocation: 0x806c930>",
    "<MyLocation: 0x806c9d0>",
    "<MyLocation: 0x806ca20>",
    "<MyLocation: 0x806cc40>",
    "<MyLocation: 0x806c990>"
)'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x02915919 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x0272a5de objc_exception_throw + 47
    2   CoreFoundation                      0x029153d9 __NSFastEnumerationMutationHandler + 377
    3   TopStation                          0x00005691 -[StationsSurLaCarteViewController requestFinished:] + 343
    4   TopStation                          0x00019597 -[ASIHTTPRequest reportFinished] + 171
    5   Foundation                          0x000abe9a __NSThreadPerformPerform + 251
    6   CoreFoundation                      0x028f6d7f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    7   CoreFoundation                      0x028552cb __CFRunLoopDoSources0 + 571
    8   CoreFoundation                      0x028547c6 __CFRunLoopRun + 470
    9   CoreFoundation                      0x02854280 CFRunLoopRunSpecific + 208
    10  CoreFoundation                      0x028541a1 CFRunLoopRunInMode + 97
    11  GraphicsServices                    0x02e8e2c8 GSEventRunModal + 217
    12  GraphicsServices                    0x02e8e38d GSEventRun + 115
    13  UIKit                               0x0033ab58 UIApplicationMain + 1160
    14  TopStation                          0x00002188 main + 102
    15  TopStation                          0x00002119 start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.
(gdb) 

EDIT 3 :
Hi again, i have to clean the map from annotations each time the view is Appeared so i did that (just before displaying annotations on the map :

if(request.responseStatusCode==200)
   {   

       for (id<MKAnnotation> annotation in mapView.annotations) {
          [mapView removeAnnotation:annotation];
       }
       //parse the response
           //...

so the exception was due to this for``loop, i erased it from the code and all works fine, however, i need really t clean the map from annotations each time the view is shown, is there another alternative to do so ?? thx in advance 🙂

  • 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-05-21T22:22:20+00:00Added an answer on May 21, 2026 at 10:22 pm

    The problem is this line:

    NSString *distance=[stationEnCours objectForKey:@"distance"];
    

    According to the NSLogs, the “distance” object in stationEnCours is an NSDecimalNumber (not a NSString). You then pass it to initWithAnnotation which assumes it is a NSString.

    When the map view tries to display the callout bubble, it also assumes the subtitle is an NSString and tries to call stringByStandardizingWhitespace on it and fails (because it’s actually an NSDecimalNumber).

    Try changing the above line to:

    NSString *distance = [NSString stringWithFormat:@"%f", 
        [(NSDecimalNumber *)[stationEnCours objectForKey:@"distance"] doubleValue]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating annotations from database. But when I click on annotation to show
I click on a link from one page that does a redirect to another
I have an MVC application that uses data annotations validation. I also have on
i have a question regarding customized annotation here. Here is how i show the
I have a UILabel that does not update on first load but does load
I currently have an image that I want people's annotations to show up on,
I have a MkMapView on which I have some Annotations. When I click an
I have a map with only one annotation.I created a simple class which I
I am developing an iPhone Application in which i have provide Pin Annotation button
Click here to see what I mean.. What could prevent these two from sitting

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.