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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:31:44+00:00 2026-05-29T04:31:44+00:00

i tired to look over SF for solution, but can’t find a solution. maybe

  • 0

i tired to look over SF for solution, but can’t find a solution.
maybe i missed it please help.

i tried to check out a user pinpoint with polygon by looping through all the KMLs.
the app always crash @ this point:

            [mapView addOverlay:overlayPolygon];

            // zoom the map to the polygon bounds
            [mapView setVisibleMapRect:overlayPolygon.boundingMapRect animated:YES];

problem code:

//create KML in hidden Mapview
-(void)loadKML:(NSMutableArray *)kmlNameArray
{    
    //dispatch_group_t group = dispatch_group_create();


    //remove polygon and redraw again.
    [NSThread detachNewThreadSelector: @selector(spinEnd) toTarget:self withObject:nil];

    [mapView removeOverlays:mapView.overlays];
    [inUserRangeArray removeAllObjects];
    [inUserRangeArrayObjectIndex removeAllObjects];
    [scrollview removeFromSuperview];
    [pageControl removeFromSuperview];
    [NSThread detachNewThreadSelector: @selector(spinBegin) toTarget:self withObject:nil];

    NSArray *sysPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES );
    NSString *docDirectory = [sysPaths objectAtIndex:0];   


    for (int e=0; e<[kmlNameArray count]; e++) 
    {        
        //NSString *kmlNameStr = [kmlNameArray objectAtIndex:e];
        Frog *kmlID = [self.fs objectAtIndex:e];
        self.kmlID = [NSString stringWithFormat:@"%i",kmlID.fID];
        self.kmlIDObjectIndex = [NSString stringWithFormat:@"%i",e];

        NSLog(@"asasas %@",kmlIDObjectIndex);

        //NSLog(@"KML items %@", kmlNameStr);          
        //NSLog(@"KML ID %@", kmlID);
        //NSLog(@"KML file Path %@",[NSString stringWithFormat:@"%@/data/%@/%@", docDirectory,self.kmlID,[kmlNameArray objectAtIndex:e]]);


        SimpleKML *kml = [SimpleKML KMLWithContentsOfFile:[NSString stringWithFormat:@"%@/data/%@/%@", docDirectory,self.kmlID,[kmlNameArray objectAtIndex:e]]error:NULL];

        // look for a document feature in it per the KML spec


        //        dispatch_group_async(group, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{

        if (kml.feature && [kml.feature isKindOfClass:[SimpleKMLDocument class]])
        {// see if the document has features of its own
            for (SimpleKMLFeature *feature in ((SimpleKMLContainer *)kml.feature).features)
            {// otherwise, see if we have any placemark features with a polygon
                if ([feature isKindOfClass:[SimpleKMLPlacemark class]] && ((SimpleKMLPlacemark *)feature).polygon)
                {
                    SimpleKMLPolygon *polygon = (SimpleKMLPolygon *)((SimpleKMLPlacemark *)feature).polygon;
                    SimpleKMLLinearRing *outerRing = polygon.outerBoundary;
                    //points[i], i = number of coordinates
                    CLLocationCoordinate2D points[[outerRing.coordinates count]];
                    NSUInteger i = 0;
                    for (CLLocation *coordinate in outerRing.coordinates)
                    { 
                        points[i++] = coordinate.coordinate;
                    }
                    // create a polygon annotation for it
                    self.overlayPolygon = [MKPolygon polygonWithCoordinates:points count:[outerRing.coordinates count]];

                    //crash here
                    [mapView addOverlay:overlayPolygon];

                    // zoom the map to the polygon bounds
                    [mapView setVisibleMapRect:overlayPolygon.boundingMapRect animated:YES];

                }
            }
        } 
    }
  • 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-29T04:31:46+00:00Added an answer on May 29, 2026 at 4:31 am

    Before you loop over the array, you can create a new array with the elements. So when the original looped array is mutated (either by you, or by its owner) the array you loop over stays intact.

    NSArray *theFeatures = [NSArray arrayWithObjects:((SimpleKMLContainer *)kml.feature).features];
    for (SimpleKMLFeature *feature in theFeatures) {
    
    }
    

    So in case of looping over the SimpleKMLContainer features directly, you create a temporary new array with those features, and loop over that array.

    Because you experience a crash on addOverlay: you must somehow be looping over the entire overlay collection. I don’t see that directly in your code, so I assume that the features collection is somehow tied to the map kit overlays.

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

Sidebar

Related Questions

I've tried to look over but couldn't find what I really want. I'm planning
What should data look like before data encoding in: urllib2.Request(someurl,data) I tried [('name1','value1'),('name2','value2'),...] but
I have tried contacting tech support with this question, but it has been over
I've been searching all over and just can't find a explanation or reason why
I tried to look for benchmark on the performances of various filesystems with MySQL
I have tried this example http://www.bennadel.com/blog/1056-ColdFusion-CFPOP-My-First-Look.htm , but it retrieve emails from POP server.
Edit: Of course my real code doesn't look exactly like this. I tried to
I tired my hands on bazaar(launchpad), for the reason that i can host my
I am new to C#, and I tried to look at the earlier posts
I'm tired of opening Dia and creating a database diagram at the beginning of

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.