Programming in objective-c: Why delegate is not calling on navigationController on newest questions tagged objective-c – Stack Overflow

I know how to use delegate pattern

  1. declare protocol
  2. required or optional method
  3. id<> delegate property
  4. [delegate respondtoselector:@selector(method)]
  5. inheriting protocol in class <someProtocol>
  6. -(void) protolcolMethod
  7. class1Obj.delegate = self;

I am using this several place in my app, but now i am doing this again in same app respondtoselector is not working. The only difference is this time its in NavController.

NavController parent tableview class didselectrow, push another view, which has button on which calls presentmadelcontroller and this is where i declared my protocol and inherited in navigationContoller parent class. But why its not working? I am struggling this for several hours.

This class is presented modally and declare this protocol

#import <CoreData/CoreData.h>

@protocol xPro <NSObject>
-(void)xGet;
@end

id<xPro> xDel;

@interface rosterForGroup : UIViewController <NSFetchedResultsControllerDelegate>
{
    NSFetchedResultsController *fetchedResultsController;
    NSArray *dispName;
}

@property (strong, nonatomic) IBOutlet UITableView *tableView;

@property (strong, nonatomic) id<xPro> xDel; 

- (IBAction)xFunc:(id)sender;

@end

.m file ...
- (IBAction)xFunc:(id)sender
{
    [xDel xGet];
}

And this class is NavController Parent class

    ...
    @interface groupChatViewController : UIViewController<XMPPRoomDelegate, createNewGroupDelegate, UITableViewDataSource, UITableViewDelegate, xPro>
    ...
    @property (strong, nonatomic) rosterForGroup *xR4G;
    ...

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    xR4G = [[rosterForGroup alloc]init];
    xR4G.xDel = self;
...

-(void)xGet
{
    NSLog(@"AAAAAAH");
}

Please avoid these strange objects name.

rosterforgroup alloc/init

- (IBAction)openGroupOptions:(id)sender
{
     roster4Group = [[rosterForGroup alloc]init];
     [roster4Group setDelegate:self];
     [self presentModalViewController:roster4Group animated:true];
     //[xmppRoom fetchMembersList];
}

See Answers


source: http://stackoverflow.com/questions/11819395/why-delegate-is-not-calling-on-navigationcontroller
Programming in objective-c: programming-in-objective-c



online applications demo