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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:04:20+00:00 2026-05-25T17:04:20+00:00

I can parse data from the database but having a hard time looping through

  • 0

I can parse data from the database but having a hard time looping through all the coordinates in the database and plotting them on the mapview. Can someone please help.

-(void)scanDatabase{

  UIDevice *device = [UIDevice currentDevice];
  NSString *uid = [device uniqueIdentifier];
  NSString *myUrl = [NSString stringWithFormat:@"http://address.php?uid=%@",uid];
  NSData *dataURL =  [NSData dataWithContentsOfURL: [ NSURL URLWithString: myUrl ]];    

  // to receive the returend value
  NSString *serverOutput =[[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];
  NSArray *components = [serverOutput componentsSeparatedByString:@"\n"];

  for (NSString *line in components) {
    NSArray *fields = [line componentsSeparatedByString:@"\t"];
    [eventPoints addObjectsFromArray:fields];

    int count = [fields count];
    for(int i=0;i < count; i++) {
      int myindex0 = i*count;
      int myindex1 = (i*count)+1;
      int myindex2 = (i*count)+2;

      NSString *mytitle = [eventPoints objectAtIndex:myindex0];
      NSNumber *myLat = [eventPoints objectAtIndex:myindex1];
      NSNumber *myLon = [eventPoints objectAtIndex:myindex2];

      CLLocationCoordinate2D loc;

      loc.latitude = myLat.doubleValue;
      loc.longitude = myLon.doubleValue;

      customAnnotation *event = [[customAnnotation alloc] initWithCoordinate:loc];
      event.title = mytitle;

      MKPinAnnotationView *newAnnotationPin = [[MKPinAnnotationView alloc] initWithAnnotation:event reuseIdentifier:@"simpleAnnotation"];
      newAnnotationPin.pinColor = MKPinAnnotationColorRed;

      [map addAnnotation:event];
    }
  }
}
  • 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-25T17:04:20+00:00Added an answer on May 25, 2026 at 5:04 pm

    Not really sure what problems you are experiencing since “having a hard time…” doesn’t describe them very well 🙂

    Looking at your code I like to make the following comments:

    • The inner loop doesn’t seem to make any sense.
    • Why don’t you access the fields directly?
    • myLat and myLon should be NSString object references.

    Maybe something like this works better:

    -(void)scanDatabase{
    
      UIDevice *device = [UIDevice currentDevice];
      NSString *uid = [device uniqueIdentifier];
      NSString *myUrl = [NSString stringWithFormat:@"http://address.php?uid=%@",uid];
      NSData *dataURL =  [NSData dataWithContentsOfURL: [ NSURL URLWithString: myUrl ]];    
    
      // to receive the returend value
      NSString *serverOutput =[[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];
      NSArray *components = [serverOutput componentsSeparatedByString:@"\n"];
    
      for (NSString *line in components) {
        NSArray *fields = [line componentsSeparatedByString:@"\t"];
        [eventPoints addObjectsFromArray:fields];
    
        if ( [fields count] != 3 ) {
          // something is wrong/unexpected here, act appropriately
        }
        else {
          NSString *mytitle = [fields objectAtIndex:0];
          NSString *myLat = [fields objectAtIndex:1];
          NSString *myLon = [fields objectAtIndex:2];
    
          CLLocationCoordinate2D loc;
    
          loc.latitude = myLat.doubleValue;
          loc.longitude = myLon.doubleValue;
    
          customAnnotation *event = [[customAnnotation alloc] initWithCoordinate:loc];
          event.title = mytitle;
    
          MKPinAnnotationView *newAnnotationPin = [[MKPinAnnotationView alloc] initWithAnnotation:event reuseIdentifier:@"simpleAnnotation"];
          newAnnotationPin.pinColor = MKPinAnnotationColorRed;
    
          [map addAnnotation:event];
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can Spirit (part of Boost C++ library) be used to parse out binary data
How i can parse and extract the parameters from an SQL Query using delphi?
Is there a built parser that I can use from C# that can parse
I'm using YAHOO.util.Connect.asyncRequest to get data from database, here is the code : function
I have a OdbcDataReader that gets data from a database and returns a set
I have the unfortunate task of having to import data from excel into a
I am having a hard time managing the storage and access of a large
currently I use DataSet to read data from ADO.NET SQL provider, but I read
could someone point me in the right direction in how i can parse data
I'm having a problem with JSTL formatDate when displaying dates from MySQL database. I

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.