ios - Call method on object from different class -


i inherited ios app 2009. in process of creating new ui it. in 1 of view controllers, have uitableview.

in old version of app, of required table view methods implemented so:

#pragma mark - #pragma mark table view methods   - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section  {     id <nsfetchedresultssectioninfo> sectioninfo = [[fetchedresultscontroller sections] objectatindex:section];     return [sectioninfo numberofobjects]; }  // customize appearance of table view cells. - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath  {     static nsstring *cellidentifier = @"speciescell";      speciescell* speciescell = (speciescell*)[tableview dequeuereusablecellwithidentifier:cellidentifier];     if (!speciescell)      {         speciescell = [[[speciescell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier] autorelease];         speciescell.frame = cgrectmake(0.0, 0.0, 320.0, row_height);     }      [speciescell setdrawshortseparator];      species *thespecies = [fetchedresultscontroller objectatindexpath:indexpath];      [speciescell setspecies:thespecies usingimagetype:currentimagetype sortby:sortbysegmentedcontrol.selectedsegmentindex];      return speciescell; } 

(the above code works fine current ui of app.)

i tried putting cellforrowatindexpath method in new view controller. unfortunately, keep getting terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[uitableviewcell setdrawshortseparator]: unrecognized selector sent instance. error of course means i'm method on object doesn't respond method.

#import "secondviewcontroller.h" #import "species.h" #import "speciestableviewcell.h" #import "speciescell.h" /*#import "homeviewcontroller.h" #import "browsehelpviewcontroller.h" #import "species.h" */  @interface secondviewcontroller () <uitableviewdatasource, uitableviewdelegate>{  }  @end  @implementation secondviewcontroller  @synthesize fetchedresultscontroller, managedobjectcontext;   #pragma mark - #pragma mark view lifecycle   - (void)viewdidload {       [super viewdidload];      uiimage *btnimage1 = [uiimage imagenamed:@"pear.png"];     _left_button.tag = 1;     [_left_button setimage:btnimage1 forstate:uicontrolstatenormal];     [_search_bar sizetofit];     [self fetchresultsusingsegmentedcontrolindex];  } /* other methods */  #pragma mark - uitableview datasource methods  - (nsinteger) tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section{     id <nsfetchedresultssectioninfo> sectioninfo = [[fetchedresultscontroller sections] objectatindex:section];     //nslog(@"number of rows %lu", (unsigned long)[sectioninfo numberofobjects]);      return [sectioninfo numberofobjects];  }  - (nsinteger)numberofsectionsintableview:(uitableview *)tableview {     return [[fetchedresultscontroller sections] count]; } // customize appearance of table view cells. - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     static nsstring *cellidentifier = @"speciescell";      speciescell* speciescell = (speciescell*)[tableview dequeuereusablecellwithidentifier:cellidentifier];     if (!speciescell)     {         speciescell = [[[speciescell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier] autorelease];         speciescell.frame = cgrectmake(0.0, 0.0, 320.0, row_height);     }      [speciescell setdrawshortseparator];      species *thespecies = [fetchedresultscontroller objectatindexpath:indexpath];      [speciescell setspecies:thespecies usingimagetype:currentimagetype sortby:sortbysegmentedcontrol.selectedsegmentindex];      return speciescell; }  @end 

however, not calling setdrawshortseparator method on uitableviewcell object - i'm calling on speciescell, object of speciescell class. @ top of viewcontroller, import speciescell.h.

i appreciate insight! thank you.

find file contains view cell , set class speciescell class. if using iboutlets should connect them too.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -