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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:17:15+00:00 2026-05-26T22:17:15+00:00

I have, what I believe to be a simple question with a simple answer

  • 0

I have, what I believe to be a simple question with a simple answer that I cannot figure out for the life of me. I’ve created a plist that I’m trying to use to populate a MapView annotation with info. I’ve gone through some tutorials and this is the code I’ve decided to go with (running a loop).

It wasn’t showing the pins on the map so I decided to set up NSLogs at different point throughout the code to find the problem and if you look at the code below, it logs out “read1” but not “read2” so it’s actually a problem somewhere in the beginning of the loop.

- (void)viewDidLoad
{
    NSMutableArray *annotations = [[NSMutableArray alloc]init];
    NSString *path = [[NSBundle mainBundle] pathForResource:@"MillersStores" ofType:@"plist"];
    NSMutableArray *anns = [[NSMutableArray alloc] initWithContentsOfFile:path];
    NSLog(@"read1");
    for(int i = 0; i < [anns count]; i++) {
        NSLog(@"read2");
        float realLatitude = [[[anns objectAtIndex:i] objectForKey:@"Latitude"] floatValue];
        float realLongitude = [[[anns objectAtIndex:i] objectForKey:@"Longitude"] floatValue];
        NSLog(@"read3");

        MillersLocations *myAnnotation = [[MillersLocations alloc] init];
        CLLocationCoordinate2D theCoordinate;
        theCoordinate.latitude = realLatitude;
        theCoordinate.longitude = realLongitude;
        myAnnotation.coordinate = theCoordinate;
        myAnnotation.title = [[anns objectAtIndex:i] objectForKey:@"Title"];
        myAnnotation.subtitle = [[anns objectAtIndex:i] objectForKey:@"Address"];
        [mapView addAnnotation:myAnnotation];
        [annotations addObject:myAnnotation];
        [myAnnotation release];
    }
}

I seem to have simple syntax errors for time to time so I’m thinking it may be something along those lines. Thanks for the help!

—

EDIT

Here’s some of the XML code of my PList file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Root</key>
    <array>
        <dict>
            <key>Title</key>
            <string>Neighborhood Market #90</string>
            <key>Address</key>
            <string>5117 Mudd Tavern Rd., Thornburg, VA 22580</string>
            <key>Latitude</key>
            <real>38.133069</real>
            <key>Longitude</key>
            <real>-77.512423</real>
            <key>Phone Number</key>
            <string>(757) 874-5806</string>
        </dict>
        <dict>
            <key>Title</key>
            <string>Neighborhood Market #89</string>
            <key>Address</key>
            <string>4902 Hampton Blvd., Norfolk, VA 23508</string>
            <key>Latitude</key>
            <real>36.887794</real>
            <key>Longitude</key>
            <real>-76.302544</real>
            <key>Phone Number</key>
            <string>(757) 440-7792</string>
        </dict>
        <dict>
            <key>Title</key>
            <string>Neighborhood Market #88</string>
            <key>Address</key>
            <string>7601 Sunset Crossing Dr., Gainesville, VA 20155</string>
            <key>Latitude</key>
                <real>38.792053</real>
            <key>Longitude</key>
            <real>-77.62994399999999</real>
            <key>Phone Number</key>
            <string>(571) 248-8580</string>
        </dict>
  • 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-26T22:17:16+00:00Added an answer on May 26, 2026 at 10:17 pm

    The plist actually contains a dictionary at the top level with one key “Root” the value of which is the array you are interested in. So you have to read the file into an NSDictionary and then retrieve the array inside it.

    Replace this line:

    NSMutableArray *anns = [[NSMutableArray alloc] initWithContentsOfFile:path];
    

    with these:

    NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];
    NSArray *anns = [dict objectForKey:@"Root"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question that's so simple I cannot believe I can't answer it
Happy Friday! I assume somebody out there has a simple answer to this question
--EDIT-- I believe this is a valid question that may have multiple answers (as
I have created a question an answer app for a client much like StackOverflow.
I can't believe that I can't find the answer to this question but I
I believe I have a potential threading issue. I have a user control that
I've recently been trying to port a C++ application. I believe I have all
I believe that I have successfully impersonated my own user account while running an
I have posted this question on the Ext-GWT forums, I am just hoping that
In a recent question asked recently my simple minded answer highlighted many of my

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.