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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:30:14+00:00 2026-06-15T07:30:14+00:00

In my app, I have a map that allows the user to drop pins

  • 0

In my app, I have a map that allows the user to drop pins onto the map. The pins geocode the address and set the address as their title. I made it so that the annotations are stored in an array when they are dropped. I have a tableview, that I want to show the addresses in the cells. I have an array in the tableview class that points to the array in the first view controller, and I somehow need to access the addresses from the array and set them as the textlabels of the cells. I already have the table view display as many cells as there are pins on the map, but I do not know how to access the information I need from the array. Here is some code to help.

Here is the first view controller:

@implementation P2OViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    [_worldView setShowsUserLocation:YES];
    NSInteger mapTypeValue = [[NSUserDefaults standardUserDefaults]
                              integerForKey:P2OMapTypePrefKey];

    // Update the UI
    [mapTypeControl setSelectedSegmentIndex:mapTypeValue];

    // Update the map
    [self changeMapType:mapTypeControl];


    UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]initWithTarget:self
                                                                                         action:@selector(press:)];
    [longPress setMinimumPressDuration:0.5f]; //user needs to press for 2 seconds
    [longPress setDelegate:self];
    [_worldView addGestureRecognizer:longPress];

    _annotationArray = [[NSMutableArray alloc]init];

    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc]init];
    [_worldView addGestureRecognizer:pan];
    number =  [NSNumber numberWithInt:0];

}

-(void)press:(UILongPressGestureRecognizer *)recognizer
{
    CGPoint touchPoint = [recognizer locationInView:_worldView];
    CLLocationCoordinate2D touchMapCoordinate = [_worldView convertPoint:touchPoint toCoordinateFromView:_worldView];

    geocoder = [[CLGeocoder alloc]init];
    CLLocation *location = [[CLLocation alloc]initWithCoordinate:touchMapCoordinate
                                                    altitude:CLLocationDistanceMax
                                          horizontalAccuracy:kCLLocationAccuracyBest
                                            verticalAccuracy:kCLLocationAccuracyBest
                                                   timestamp:[NSDate date]];
    [geocoder reverseGeocodeLocation:location
                   completionHandler:^(NSArray *placemarks, NSError *error) {
                       NSLog(@"reverseGeocoder:completionHandler: called");
                       if (error) {
                           NSLog(@"Geocoder failed with error: %@", error);
                       } else {
                           CLPlacemark *place = [placemarks objectAtIndex:0];
                           geocodedAddress = [NSString stringWithFormat:@"%@ %@, %@ %@", [place subThoroughfare], [place thoroughfare], [place locality], [place administrativeArea]];
                           if (UIGestureRecognizerStateBegan == [recognizer state]) {
                               value = [number intValue];
                               number = [NSNumber numberWithInt:value + 1];
                               addressPin = [[MapPoint alloc]initWithAddress:geocodedAddress coordinate:touchMapCoordinate
                                                                   title:geocodedAddress identifier:number];
                               NSLog(@"The identifier is %@", number);
                               [_annotationArray addObject:addressPin];
                               [_worldView addAnnotation:addressPin];
                               NSLog(@"The number of pins in the annotation array is: %u",_annotationArray.count);
                           }
                       }
                   }];
}


-(void)mapView:(MKMapView *)mapView
annotationView:(MKAnnotationView *)view
calloutAccessoryControlTapped:(UIControl *)control
{
    PinViewController *pvc = [[PinViewController alloc]init];
    [[self navigationController]pushViewController:pvc
                                      animated:YES];
    pvc.label.text = view.annotation.title;
}  

- (IBAction)bookmarkPressed:(id)sender
{
    P2OTableViewViewController *tvc = [[P2OTableViewViewController alloc]initWithStyle:UITableViewStyleGrouped];
    [tvc setValue:_annotationArray];
    [[self navigationController]pushViewController:tvc
                                      animated:YES];
}
@end

Here is my TableViewController

#import <UIKit/UIKit.h>
@class P2OViewController;

@interface P2OTableViewViewController : UITableViewController
{
    NSMutableArray *_pinArray;
    __weak P2OViewController *_pvc;
}

@property (readonly) UILabel *textLabel;
@property (weak,nonatomic) P2OViewController *pvc;
@property (strong,nonatomic) NSMutableArray *pinArray;

-(void)setValue:(NSMutableArray *)value;
@end

@implementation P2OTableViewViewController

@synthesize pinArray = _pinArray, pvc = _pvc;

- (id)init
{
    self = [super initWithStyle:UITableViewStyleGrouped];
    if (self) {
        _pinArray = [[NSMutableArray alloc]init];
    }
    return self;
}

-(void)setValue:(NSMutableArray *)value
{
   _pinArray  = value;
}

-(id)initWithStyle:(UITableViewStyle)style
{
    return [self init];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
    // Return the number of rows in the section.
    return _pinArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }


    return cell;
}

So basically I want the title of the annotations in the array to be the textlabel for the cells. So if there are 5 pins in the array, I want the 5 cells to have the corresponding addresses of the annotations (the title property) as the textlabels. I would appreciate the help.

  • 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-15T07:30:15+00:00Added an answer on June 15, 2026 at 7:30 am

    Before return cell;, you can do cell.textLabel.text = [_pinArray objectAtIndex:indexPath.row] Make sure you’re extracting the title property from _pinArray.

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

Sidebar

Related Questions

I have a relatively simple web app, that allows the user to enter two
I have an app that saves google map markers, I basically save the lat
I have an App that displays thousands of Pin annotations on a google map
I'm writing a simple App Engine app. I have a simple page that allows
I'm currently building an app that allows the user to keep track of the
I hope someone can help with this. I have created a map app that
I have a MKMapView and in the Map View Show User Location is set.
I have an android app that allows users to take photos. In that effort,
I have an app which has a map and some POI on it. I'm
I have displayed the map in my app by using the following code. 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.