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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:06:51+00:00 2026-05-24T23:06:51+00:00

I have a php file on my server that outputs each user’s name and

  • 0

I have a php file on my server that outputs each user’s name and location, in coordinate format like this:

user1: 34.208495,-83.411488
user2: 34.208434,-83.411443
user3: 34.208456,-83.411467

I am using this to download and parse the file:

NSString *myUrl = [NSString stringWithFormat:@"http://mysite.com/users/getlocations.php"];
NSURL *url = [NSURL URLWithString:myUrl];
[myWeb loadRequest:[NSURLRequest requestWithURL:url]];
NSString *string = [myWeb stringByEvaluatingJavaScriptFromString:@"document.documentElement.innerText"];   

NSArray *components = [string componentsSeparatedByString:@"\n"];

[locationArray addObjectsFromArray:components];

And this to put a pin on the map:

NSMutableArray* points = [[NSMutableArray alloc] initWithCapacity:100];
CLLocationDegrees latitude  = lat;
CLLocationDegrees longitude = longi;
CLLocation* currentLocation = [[[CLLocation alloc] initWithLatitude:latitude longitude:longitude] autorelease];
[points addObject:currentLocation];    

CSMapAnnotation* annotation = nil;
annotation = [[[CSMapAnnotation alloc] initWithCoordinate:[[points objectAtIndex:0] coordinate]
                                           annotationType:CSMapAnnotationTypeImage
                                                    title:username] autorelease];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[mapView addAnnotation:annotation];         
[UIView commitAnimations];

I basically need to parse the file in a way that sets the username as the pin’s title and the coordinates as the pin’s coordinates.

Thanks a lot!

  • 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-24T23:06:51+00:00Added an answer on May 24, 2026 at 11:06 pm

    Just a thought…

    NSString *input = ...the list of user locations....
    NSArray *locationArray = [input componentsSeparatedByString:@","];
    

    instead of this format, however:
    user3: 34.208456,-83.411467

    this method requires this format: user3, 34.208456,-83.411467,

    Also, get rid of the breaklines. Basically, you would be generating a CSV file, and then creating an array of all the values in the array. Not ideal, but to get the number of users, for example, you could write:

    int numUsers = [locationArray count]/3.0f;
    

    The render all these positions on a map, you would just parse through the array to grab the data for each user.

    It would probably be better and more efficient to use some sort of XML file, though. That way you wouldn’t necessarily have to keep all the user location data in memory at all times, and it would be easier to parse.

    EDIT:

    so, for example, if you wanted three strings representing the user data for a give user, you might use code like this:

    NSString *username;
    float lat;
    float lon;
    
    
    /*
    index represents the user from which you are grabbing data.
    I'm arbitrarily setting the index to 5, meaning you would get data
    for the 5th user listed.
    */
    int index = 5;
    
    username = [locationArray objectAtIndex:3*index];
    lat = [[locationArray objectAtIndex:3*index+1] floatValue];
    lon = [[locationArray objectAtIndex:3*index+2] floatValue];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SOLVED: Error in template file I have Smarty setup like this: require_once 'smarty/Smarty.class.php'; $smarty
I have a simple PHP script that outputs a dir listing in XML format.
I have a PHP file which will return something like <div id=title>Add Us On
I have a PHP file that contains a lot of if and else statements
I have a php file somejson.php that echos a json encoded array {jsonone:first json,jsontwo:second
I have a php file that I am trying to send the output in
OK, I have defined a PHP constant that points to a file on the
I have CMS with a script that is executed for each file that is
I have a php script that outputs a json-encoded object with large numbers (greater
I have a PHP script (running on a Linux server) that ouputs the names

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.