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

  • Home
  • SEARCH
  • 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 7774927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:30:04+00:00 2026-06-01T17:30:04+00:00

I am writing an iOS 5 app which tracks a user’s location in real-time,

  • 0

I am writing an iOS 5 app which tracks a user’s location in real-time, plotting their course on a MKMapView. Whenever a GPS reading is taken I would like a polyline to be drawn between the current and old locations, eventually forming a track (or breadcrumb) of where the user has travelled.

I am comfortable with using MKPolyline and MKPolylineView to draw a track, assuming that I have all the CLLocationCoordinate2D coordinates in advance, using code similar to below:

MKPolyline *route = [MKPolyline polylineWithCoordinates:coordinates count:[self.coordinateArray count]];        
[mapView addOverlay:route];

However, since I am only getting the CLLocationCoordinate2D coordinates in real-time (as the locationManager:didUpdateToLocation:fromLocation: delegate method is called) I am unsure of the best way to draw the new polylines.

Can I extend the existing lines (i.e. adding to the C-based coordinates array – not having much C experience I am unsure how to do this) or do I need to create a new polyline between the next two coordinates (although I have heard that having too many individual polylines on the map can impact performance and memory usage…)?

Thanks 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-06-01T17:30:06+00:00Added an answer on June 1, 2026 at 5:30 pm

    First, see how to update MKPolyline / MKPolylineView?, especially the link to the the Breadcrumb sample code. It may be a good starting point for what you need.

    However, you’ll see that a vital part of its CrumbPath object is a call to realloc. So yes, you need to know how to manage C-style arrays if you want to efficiently store your arrays of points. Yes, this is not easy. Yes, C-style array manipulation is an invitation for memory leaks.

    The Breadcrumb sample uses realloc to resize its array. You can be a bit safer by allocating the memory the array uses with the NSMutableData type. It is recommended as an answer to Is it ok to use “classic” malloc()/free() in Objective-C/iPhone apps?. Read the other solutions to see regular C malloc() and free() functions doing the same job. Note that NSMutableData has a very handy increaseLengthBy: method.

    When you understand why every C student attempts to use sizeof() incorrectly – and how to use it properly – you will understand C memory management.

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

Sidebar

Related Questions

I'm writing a mobile marketing app, which is supposed to work on both iOS
I'm writing an iOS app which needs to generate and animate individual text characters
I'm writing an ios app which browses(read only) a sqllite db. As the project
I'm writing an iPhone app (which will be my first ios app) that has
Im currently writing an ios app which uses google map api's to measure driving
I am writing an enterprise client/server application. The client is an iOS app which
I am writing an ios app that talks to the asp.net server by using
I'm writing an iOS app that acts as, among other things, a telnet server.
My company is currently writing an iOS app whereby we will display some of
I'm writing an iOS 5 app (in Xcode 4.3, using Storyboards and ARC) that

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.