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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:13:28+00:00 2026-06-09T19:13:28+00:00

I am very new to XCode and objective-c. This question may have been answered

  • 0

I am very new to XCode and objective-c. This question may have been answered previously but I am somehow not able to make it work. My objective is to show multiple annotations on Google map. I have a bunch of Lats and Longs, however so far I have been able to show only one annotation. How can I show All the annotations at once. I have the code below for the MKMapView–

- (void)viewDidLoad {

    // Set some coordinates for our position
    CLLocationCoordinate2D location;

    location.latitude = (double) 44.271745;
    location.longitude = (double) -88.453265;   
    // Add the annotation to our map view
    MapViewAnnotation *newAnnotation = [[MapViewAnnotation alloc] initWithTitle:@"Appleton" andCoordinate:location];
    [self.mapview addAnnotation:newAnnotation];

    [newAnnotation release];

    self.mapview.region = MKCoordinateRegionMakeWithDistance(location,100000,100000);
}

I understand that I can loop through and instantiate newAnnotation and then use addAnnotation to add the annotation. But I am somehow not getting how to do it. This may be very basic, but I am very new to this. Any help will be appreciated.

//
//  MapViewAnnotation.h
//

#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>

@interface MapViewAnnotation : NSObject <MKAnnotation> {

    NSString *title;
    CLLocationCoordinate2D coordinate;

}

@property (nonatomic, copy) NSString *title;
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;

- (id)initWithTitle:(NSString *)ttl andCoordinate:(CLLocationCoordinate2D)c2d;

@end

And

//
//  MapViewAnnotation.m
//

#import "MapViewAnnotation.h"


@implementation MapViewAnnotation
@synthesize title, coordinate;

- (id)initWithTitle:(NSString *)ttl andCoordinate:(CLLocationCoordinate2D)c2d {
    [super init];
    title = ttl;
    coordinate = c2d;
    return self;
}

- (void)dealloc {
    [title release];
    [super dealloc];
}
@end
  • 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-09T19:13:30+00:00Added an answer on June 9, 2026 at 7:13 pm

    Looks like you only have one location. You should have list of latitude and longitude, then loop through that list and instantiate the MapViewAnnotation.

    - (void)viewDidLoad {
        NSArray *arrayOfLatLong = [NSArray arrayWithObjects: [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"10.22", @"20.212", nil] forKeys:[NSArray arrayWithObjects:@"Lat",@"Long",nil]], 
                                   [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"10.22", @"24.5", nil] forKeys:[NSArray arrayWithObjects:@"Lat",@"Long",nil]], nil];
    
    
        for(NSDictionary *location in arrayOfLatLong) {
            CGFloat latitude = [[location valueForKey:@"Lat"] floatValue];
            CGFloat longitude = [[location valueForKey:@"Long"] floatValue];
    
            CLLocationCoordinate2D location;
            location.latitude = latitude;
            location.longitude = latitude;   
            MapViewAnnotation *newAnnotation = [[MapViewAnnotation alloc] initWithTitle:@"Appleton" andCoordinate:location];
            [self.mapview addAnnotation:newAnnotation];
    
            [newAnnotation release];
            self.mapview.region = MKCoordinateRegionMakeWithDistance(location,100000,100000);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello all! I am very new to xcode and objective-c but I have been
I'm new to Xcode. This is probably a very simple question to you, but
I am new to iphone and xcode. This may be a very simple question
I am very new to xcode & Objective-C (having come from PHP) i have
Im very new to xcode and i have a question to my first app.
Very new to python and can't understand why this isn't working. I have a
Very new to Objective-C and Xcode and working my way through modifying the DrillDownApp
I am new to Mac, iOS, Xcode and objective-c. I am very familiar with
First, I am super-new to Objective-C/iOS development and, in fact, this question is for
Hi there I am new to C programming and have been using Xcode to

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.