iphone - TableView not displaying correctly and crashing, -
i have tableview in midddle of tab bar template application.. wanted add contents of nsmutablearray called 'routines'.
here .h file
#import <uikit/uikit.h> @interface firstviewcontroller : uiviewcontroller <uitableviewdelegate, uitableviewdatasource> { nsmutablearray *routines; } @property (nonatomic, retain) nsmutablearray *routines; - (ibaction)showneweventviewcontroller; @end
and .m file.
#import "firstviewcontroller.h" #import "neweventviewcontroller.h" @implementation firstviewcontroller @synthesize routines; - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { return [routines count]; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [[[uitableviewcell alloc] initwithframe:cgrectzero reuseidentifier:cellidentifier] autorelease]; } // set cell... nsstring *cellvalue = [routines objectatindex:indexpath.row]; [cell.textlabel settext:cellvalue]; return cell; }
and viewdidload method
- (void)viewdidload { routines = [[nsmutablearray alloc] init]; [routines addobject:@"hello"]; [routines addobject:@"temp"]; [routines addobject:@"temp2"]; [routines addobject:@"temp3"]; [routines addobject:@"temp4"]; self.navigationitem.title = @"test"; }
my objects not displaying. can see, have added
and have hooked in ib correctly.
when try open app ( return) crashes, , spits out following log.
[session started @ 2010-01-19 17:57:01 +1300.] 2010-01-19 17:57:03.563 gym buddy[12690:207] *** -[uitabbarcontroller tableview:numberofrowsinsection:]: unrecognized selector sent instance 0x3b12450 2010-01-19 17:57:03.564 gym buddy[12690:207] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '*** -[uitabbarcontroller tableview:numberofrowsinsection:]: unrecognized selector sent instance 0x3b12450' 2010-01-19 17:57:03.577 gym buddy[12690:207] stack: ( 29295707, 2538743049, 29677627, 29247094, 29099714, 4364410, 4371786, 4370783, 3087322, 3027833, 3069268, 3057823, 55808688, 55808111, 55806150, 55805242, 2731769, 2755464, 2737875, 2764981, 37392081, 29080448, 29076552, 2731625, 2768899, 9784, 9638 )
i have no idea going wrong, since im bit of newbie.
thanks guys!
sam
it looks you've assigned datasource of table uitabbarcontroller, rather firstviewcontroller object. second line of pasted error message saying it's trying numberofrows, datasource doesn't implement it. double check connections in ib.
Comments
Post a Comment