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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:07:12+00:00 2026-06-13T13:07:12+00:00

I add a NSTimer to record the location from location manager ,and put ever

  • 0

I add a NSTimer to record the location from location manager ,and put ever location into a NSMutableArray.

-(void)OnTimer:(NSTimer *)param{
     [self.locationRecoder addObject:self.manager.location];
}

and I add a button to UI, when I click the button, it invoke this method

-(IBAction)Click:(id)sender(){
   NSArray *coordinateArray = [self.locationRecorder valueForKeyPath:@"coordinate"];
   MKPolyline *lines = [MKPolyline ploylineWithCoordinates:(CLLocationCoordinate2D *)coordinateArray count:coordinateArray.count];
   [self.map addOverlay:lines];
}

then there is nothing drawn. did i do something wrong in type cast?

  • 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-13T13:07:12+00:00Added an answer on June 13, 2026 at 1:07 pm

    The polylineWithCoordinates method requires a plain C array of structs of type CLLocationCoordinate2D.

    After the call to valueForKeyPath, coordinateArray is an NSArray of NSValue objects.
    That is not the same thing as a C array of structs.

    Casting that NSArray to (CLLocationCoordinate2D *) doesn’t convert it to a C array of structs.

    Instead, you have to create the C array manually using malloc and looping through the locationRecoder array:

    CLLocationCoordinate2D *coordinateArray 
        = malloc(sizeof(CLLocationCoordinate2D) * locationRecorder.count);
    
    int caIndex = 0;
    for (CLLocation *loc in locationRecorder) {
        coordinateArray[caIndex] = loc.coordinate;
        caIndex++;
    }
    
    MKPolyline *lines = [MKPolyline polylineWithCoordinates:coordinateArray 
                            count:locationRecorder.count];
    
    free(coordinateArray);
    
    [self.map addOverlay:lines];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

// Add the button to the NSMutableArray. ... UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; [[self
I add a EditText into a Linearlayout, for each ,I set a picture as
I add a NSTimer in the iphone application。When I run the application,it‘s failed。I have
Add next changes: Emily::oSeMac^ Terminal; Emily::AsyncSocketController^ _socketManager; delegate void DataArrival(String^, array<unsigned char, 1>^, System::Net::IPEndPoint^);
Lets add a new group and user and add it into system group video
I want to add a array of UIImages to UIImageView using NSTimer. Such that
I'm using NSTimer (5 second duration) with selector to select randomly name from NSArray.
If I create a timer which never repeats [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(updateSystems) userInfo:nil repeats:NO];
I'm trying to add a feature into my app that allows the user to
OK,First this program can load plist from URL by this code,and I put this

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.