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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:09:22+00:00 2026-06-03T04:09:22+00:00

I am working on an iPad app that has a main view (In this

  • 0

I am working on an iPad app that has a main view (In this case an MKMapView) with a PopoverView controller which contains a UITableViewController. The content in the UITableview contains a number of variable elements which I need for dropping annotation pins on the MapView. These variables change depending on which row is selected. My thought was to use a delegate to accomplish this but I am struggling to implement it.

I have declared delegate in the showIncidentList method (see enclosed code). My questions are, is this custom delegate appropriate for this desired outcome, and if so, what am i missing that will allow me to communicate the information in the delegate and call the plotCallLocations method on the main view with the updated information from the delegate.

Relevent code:

SearchViewController.h //the popoverViewController class

@protocol IncidentPickerDelegate <NSObject>

- (void)incidentSelected:(NSMutableArray *)incidentDetail;

@end

@interface SearchViewController : UITableViewController  <UITableViewDelegate, UITableViewDataSource> { 
__weak id<IncidentPickerDelegate> _delegate;
}

@property (nonatomic, retain) NSMutableArray *incidentDetails;
@property (nonatomic, weak) id<IncidentPickerDelegate> delegate;
@end

SearchViewController.m

#import "TwitterSearchViewController.h"
#import "CallViewController.h"

@implementation SearchViewController

@synthesize delegate = _delegate;
@synthesize incidentDetails= _incidentDetails;

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

_incidentDetails = [[NSMutableArray alloc] initWithObjects:[textItems objectAtIndex:0], [textItems objectAtIndex:1], lat, lon, nil];     //textItems is an NSArray of parsed JSON data, lat and lon are int's

 NSLog(@"_delegate = %@", _delegate);
        if ([_delegate respondsToSelector:@selector(incidentSelected:)]) {
            NSMutableArray *incidentDet = _incidentDetails;
            [_delegate incidentSelected:incidentDet];
 NSLog(@"incidentDetail ----> %@", incidentDet);
} 

@end

CallViewController.h //MainViewController

#import "SearchViewController.h"

@interface CallViewController : UIViewController <CLLocationManagerDelegate, MKMapViewDelegate, UIAlertViewDelegate, IncidentPickerDelegate> {
}

@property (nonatomic, retain) UIPopoverController *incidnetListPopover;
@property (nonatomic, retain) SearchViewController *incidentPicker;

-(IBAction)showIncidentList:(id)sender;

CallViewController.m

#import "CallViewController.h"
#import "SearchViewController.h"

@implementation CallViewController

@synthesize incidnetListPopover = _incidnetListPopover;
@synthesize incidentPicker = _incidentPicker;

UIStoryboard*  sb = [UIStoryboard storyboardWithName:@"MainStoryboard"
                                              bundle:nil];

if (_incidentPicker == nil) {
    self.incidentPicker = [sb instantiateViewControllerWithIdentifier:@"SearchViewController"];
    _incidentPicker.delegate = self;

    self.incidnetListPopover = [[UIPopoverController alloc] 
                                initWithContentViewController:_incidentPicker];               
}

[self.incidnetListPopover presentPopoverFromBarButtonItem:sender 
                                permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

}


- (void)incidentSelected:(NSMutableArray *)incidentDetail {


//    for (id<MKAnnotation> annotation in _mapView.annotations) {
//      [_mapView removeAnnotation:annotation];

NSLog(@"plotCall called");
NSNumber * latitude = [incidentDetail objectAtIndex:2];
NSNumber * longitude = [incidentDetail objectAtIndex:3];
NSString * name = [incidentDetail objectAtIndex:1];
NSString * address = [incidentDetail objectAtIndex:0];
CLLocationCoordinate2D coordinate;
coordinate.latitude = latitude.doubleValue;
coordinate.longitude = longitude.doubleValue;  

CallLocation *annotation = [[CallLocation alloc] initWithName:name address:address coordinate:coordinate];
[_mapView addAnnotation:annotation];  

[self.incidnetListPopover dismissPopoverAnimated:YES];

}
  • 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-03T04:09:23+00:00Added an answer on June 3, 2026 at 4:09 am

    The custom delegate approach is fine for this situation.

    The main problem is that CallViewController does not implement the exact method specified in the IncidentPickerDelegate protocol which is incidentSelected:. (By the way, I assume “TwitterSearchViewController” is a typo and should be “SearchViewController” or vice versa.)

    Even though CallViewController has the method plotCallLocations: which also takes an array, it is not named exactly incidentSelected: (it needs to be).

    You should be getting some compiler warnings about this.

    So when the SearchViewController calls that protocol method, it probably crashes with an “unrecognized selector” error.

    Here are some solutions (first one is the easiest):

    • In CallViewController, change plotCallLocations: to incidentSelected:
    • In the protocol, change incidentSelected: to plotCallLocations:
    • In CallViewController, add a incidentSelected: method and from there, call plotCallLocations:

    Separately (not causing an issue but), in SearchViewController, instead of checking if the delegate is nil, it’s better to check if the delegate actually has the method you’re about to call using respondsToSelector:.

    To do this, first you’ll have to make IncidentPickerDelegate implement the NSObject protocol:

    @protocol IncidentPickerDelegate<NSObject>
    

    Now in SearchViewController, instead of checking if the delegate is nil:

    if ([_delegate respondsToSelector:@selector(incidentSelected:)])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working in an iPad app that has a split view with a navigation
I am working on an iPad app which has an embedded HTTP server listening
I'm working on a simple iPad app which has an animation of 12 separate
I am working on an iPad app, and one of the features that has
I am working on an MKMapView based iPhone / iPad mapping app that overlays
I've been working on an iPad application that has about 15 view controllers. Some
I'm working on an iPad app that downloads a CSV file from the web
So I am working on an iPad app that needs to talk to our
I'm working on an app that stores data locally on the iPad in the
I am working on a Phonegap App that has dynamically created elements. The app

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.