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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:36:10+00:00 2026-05-24T20:36:10+00:00

I seem to have an odd problem while trying to add objects to a

  • 0

I seem to have an odd problem while trying to add objects to a mutable array. The thing is I have an array of dictionaries with coordinates that I get from an external database and I try to do a loop through them, extract the coordinates, create a custom annotation object and then add it to a mutable array.

The problem is the array I get them in shows that it only has 1 object and the first array has 5.

Please help!

Here is the code (remark: testArray is a property on my class i don’t create it bellow, i just try to use it to store the objects)

Thanks!

int times;
int count;

count=[theResults count];

// do the loop oh yeah do the loop 

for (times=0;times<count; times=times+1)
{
// create dictionary with contents of array

NSDictionary * testDict = [theResults objectAtIndex:times];

NSLog(@"the results has %i objects", [theResults count]);


NSLog(@"object latitude is %@",[radarDict valueForKey:@"radarLatitude"]);
NSLog(@"object longitude is %@", [radarDict valueForKey:@"radarLongitude"]);


double testLatitude=[[radarDict valueForKey:@"radarLatitude"] doubleValue];
double testLongitude=[[radarDict valueForKey:@"radarLongitude"] doubleValue];

CLLocationCoordinate2D testCoordinate;
testCoordinate.longitude=testLongitude;
testCoordinate.latitude=testLatitude;

    CustomAnnotations* tempAnnotation = [[CustomAnnotations alloc] initWithLocation:testCoordinate];

    testArray = [[NSMutableArray alloc] initWithCapacity:count];

    [testArray addObject:tempAnnotation];        
    [tempAnnotation release];
}
  • 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-24T20:36:11+00:00Added an answer on May 24, 2026 at 8:36 pm

    You are blasting away your array every time you run through the loop. This line is killing you:

    testArray = [[NSMutableArray alloc] initWithCapacity:count];
    

    Put that before the loop starts and you will be fine.

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

Sidebar

Related Questions

I have an odd problem that I just can't seem to diagnose, and it
I have an extremely odd problem in my JUnit tests that I just can't
I seem to be encountering a very odd problem which only occurs when trying
I'm having a very odd problem that I can't seem to track down. Any
I seem to have a problem with this SQL query: SELECT * FROM appts
I seem to have an app on my Dev server that has lots of
I seem to have a problem with getting MVC to fill in my custom
I seem to have the exact opposite problem than this question on stopping dock
I seem to have a problem understanding how to conditionally test a boolean value
This is a really odd situation that I can't seem to work out where

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.