El método del protocolo personalizado no está llamando en iphone sdk

I am having RouteSelectController from which I am navigating to RouteInfoController.

-(void)GoToRouteInfo
{
    RouteInfoController *controller = [[RouteInfoController alloc] initWithNibName:@"RouteInfoController" bundle:nil];

controller.delegate = self;
[self.navigationController pushViewController:controller animated:YES];
[controller release];
}

In RouteInfoController.h I am creating my customized protocol like

#import <UIKit/UIKit.h>
@protocol RouteInfoDelegate;
@interface RouteInfoController : UIViewController<UITableViewDelegate, UITableViewDataSource, WptInfoDelegate>
{

    id<RouteInfoDelegate> delegate;
}
@property (nonatomic, assign) id delegate
@end

@protocol RouteInfoDelegate

- (void) deleteWptFromRouteAndAppWithUID;

@end

In RouteInfoController.m I called this delegate method like:

#import "MapViewController.h"
@class MapViewController;
@implementation RouteInfoController
@synthesize delegate;

-(void)callRouteDelegateMethod
{
  [self.delegate deleteWptFromRouteAndAppWithUID];
}

And the definition of this method is in MapViewController.m like:

#import "RouteInfoController.h"
@interface MapViewController () <UIScrollViewDelegate,RouteInfoDelegate>
{
    //.....................................
}

-(void) deleteWptFromRouteAndAppWithUID // The problem here is this delegate method is not called
{
    NSLog(@"\n Inside delete Way point...");

}

Edit: And when the control reaches to that delegate method in

-(void)callRouteDelegateMethod

in RouteInfoController I am get a crash message in my console like :

[RouteSelectController deleteWptFromRouteAndAppWithUID]: unrecognized selector sent to instance 0x6eb4eb0

Edit2:

In RootInfoController I am having a method on didselect of any cell of table view it calls this method

- (void) viewWptInfoControllerAtIndex: (int)index{

    WptInfoViewController *controller = [[WptInfoViewController alloc] initWithNibName:@"WptInfoViewController" bundle:nil];
    controller.asRootController = NO;
    controller.delegate = self;
    NSMutableDictionary *dict = [route.routeWaypoints objectAtIndex:index];
    NPLibWaypoint *libWpt = [NPLibWaypoint initWithDictionary:dict AndDelegateDS:delegateDS];
    controller.libWpt = libWpt;
       [libWpt release];
    controller.isFromRouteInfo = YES;
    [self.navigationController pushViewController:controller animated:YES];
    [controller release];

}

Guy's cpls anyone suggest me How to resolve this and what's wrong I done.

Anyone's Help is deeply Appreciated.

Thanks All, Monish.

preguntado el 10 de marzo de 12 a las 07:03

where does "RouteSelectController" come from? i thought you wanted to use MapViewController as your delegate.. maybe you set the delegate wrong? -

Thats wt I am confused y RouteSelectorController came in between.I done same as I posted the code on this Question. -

please show us the code where you set the delegate object -

None of the classes you posted here conform to the formal protocol RouteInfoDelegate. MapViewController appears to conform to a RouteDelegate protocol; but I don't see any declaration of that protocol listed here. -

In your first block of code, you assign the delegate of the instance of RouteInfoController de las personas acusadas injustamente llamadas RouteSelectController that instantiates it. But the error is telling you that RouteSelectController doesn't implement the delegate method. So Martin Ullrich's comment is correct - you're assigning the delegate wrong. -

1 Respuestas

The error you're getting is pretty straightforward. It means that you're sending the message -deleteWptFromRouteAndAppWithUID a una instancia de RouteSelectController, and that that class doesn't have that method. Some things to consider:

  • spelling: If you think that you've defined that method in that class, carefully check the spelling of the method name to make sure that the method you're calling exactly matches the name of the method that you've implemented. It's a pretty long name, and it'd be easy to get wrong. Remember that capitalization counts, as does the colon (or lack of colon).

  • receptor: Check that the object that's receiving the message really is the object that you intended. This message crops up sometimes when you've got a bad pointer, causing a case of mistaken identity.

It looks like it's the second point that's the problem in your case -- you've got an implementation of the method in MapViewController, but the error message indicates that that message is being sent to an instance of a different class (RouteSelectController). You may be changing RouteInfoController's delegate explicitly in your code somewhere, so look for that. But it may be the case that your RouteInfoController's delegate object is for some reason being deallocated, and a RouteSelectController happens to be created subsequently at that same address. When that happens, delegate points to the right place, but the wrong object is now there, and the error results.

respondido 13 mar '12, 10:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.