iphone - Why am I getting a "unrecognized selector" error when I click on a button? -


when click on of toobar buttons, :

terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[addrecipientstableviewcontroller btnremoterecipients:]: unrecognized selector sent instance 0x4b87b10'

header file

@interface addrecipientstableviewcontroller : uitableviewcontroller {  }  -(ibaction) btnlocalrecipients; -(ibaction) btnremoterecipients;   @end 

interface file

#import "addrecipientstableviewcontroller.h"   @implementation addrecipientstableviewcontroller     -(ibaction) btnlocalrecipients{   } -(ibaction) btnremoterecipients{   }   #pragma mark - #pragma mark view lifecycle   - (void)viewdidload {     [super viewdidload];            // uncomment following line display edit button in navigation bar view controller.     // self.navigationitem.rightbarbuttonitem = self.editbuttonitem; }    - (void)viewwillappear:(bool)animated {     [super viewwillappear:animated];       self.navigationitem.title = @"add recipients";      self.navigationcontroller.toolbarhidden=no;       uibarbuttonitem            *localitem;     uibarbuttonitem            *remoteitem;       localitem = [[ uibarbuttonitem alloc ] initwithtitle: @"local"                                                    style: uibarbuttonitemstylebordered                                                   target: self                                                   action: @selector( btnlocalrecipients: ) ];        remoteitem = [[ uibarbuttonitem alloc ] initwithtitle: @"remote"                                                     style: uibarbuttonitemstylebordered                                                    target: self                                                    action: @selector( btnremoterecipients: ) ];      self.toolbaritems = nil ;      self.toolbaritems = [ nsarray arraywithobjects: localitem,remoteitem,nil ];      [localitem release];     [remoteitem release];   }  /* - (void)viewdidappear:(bool)animated {     [super viewdidappear:animated]; } */  - (void)viewwilldisappear:(bool)animated {     [super viewwilldisappear:animated];      self.navigationcontroller.toolbarhidden=yes;   }  /* - (void)viewdiddisappear:(bool)animated {     [super viewdiddisappear:animated]; } */ /* // override allow orientations other default portrait orientation. - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation {     // return yes supported orientations.     return (interfaceorientation == uiinterfaceorientationportrait); } */   #pragma mark - #pragma mark table view data source  - (nsinteger)numberofsectionsintableview:(uitableview *)tableview {     // return number of sections.     return 1; }   - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section {     // return number of rows in section.     return 1; }   // customize appearance of table view cells. - (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] autorelease];     }      // configure cell...      return cell; }   /* // override support conditional editing of table view. - (bool)tableview:(uitableview *)tableview caneditrowatindexpath:(nsindexpath *)indexpath {     // return no if not want specified item editable.     return yes; } */   /* // override support editing table view. - (void)tableview:(uitableview *)tableview commiteditingstyle:(uitableviewcelleditingstyle)editingstyle forrowatindexpath:(nsindexpath *)indexpath {      if (editingstyle == uitableviewcelleditingstyledelete) {         // delete row data source.         [tableview deleterowsatindexpaths:[nsarray arraywithobject:indexpath] withrowanimation:uitableviewrowanimationfade];     }        else if (editingstyle == uitableviewcelleditingstyleinsert) {         // create new instance of appropriate class, insert array, , add new row table view.     }    } */   /* // override support rearranging table view. - (void)tableview:(uitableview *)tableview moverowatindexpath:(nsindexpath *)fromindexpath toindexpath:(nsindexpath *)toindexpath { } */   /* // override support conditional rearranging of table view. - (bool)tableview:(uitableview *)tableview canmoverowatindexpath:(nsindexpath *)indexpath {     // return no if not want item re-orderable.     return yes; } */   #pragma mark - #pragma mark table view delegate  - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {     // navigation logic may go here. create , push view controller.     /*     <#detailviewcontroller#> *detailviewcontroller = [[<#detailviewcontroller#> alloc] initwithnibname:@"<#nib name#>" bundle:nil];     // ...     // pass selected object new view controller.     [self.navigationcontroller pushviewcontroller:detailviewcontroller animated:yes];     [detailviewcontroller release];     */ }   #pragma mark - #pragma mark memory management  - (void)didreceivememorywarning {     // releases view if doesn't have superview.     [super didreceivememorywarning];      // relinquish ownership cached data, images, etc. aren't in use. }  - (void)viewdidunload {     // relinquish ownership of can recreated in viewdidload or on demand.     // example: self.myoutlet = nil; }   - (void)dealloc {     [super dealloc]; }   @end 

you need add :(id) sender in functions btnlocalrecipients , btnremoterecipients. try with

-(ibaction) btnlocalrecipients:(id) sender{   } -(ibaction) btnremoterecipients:(id) sender{   } 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -