开发者

Where should I create NSArray for using as DataSource in my TableView

could anybody explain me: where should I create NSArray (I would like to use it in my ViewController class in DataSourseDelegate's methods).

I tried to create it in init, viewDidLoad, viewWillAppear methods, but or get error or this array is empty.

My controller .h file:

@interface SendingController : UITableViewController <UITableViewDelegate, UITableViewDataSource> {
NSArray *arrDataSource;
}
@property (nonatomic, retain) NSArray *arrDataSource;

Or maybe is there the better way in such situation: I use tableView in Navigation interface, and number of section, it names (I use this Array right here) and rows 开发者_运维百科in section defined value (I need table view only to choose disclosure indicator in row to push new controller in Nav stack). How and where should I predefined names of section etc ?? In DataSourceDeleagte's methods ?


The data source of your table view is actually designed for returns such names. The UITableViewDataSource protocol defines in particular two methods :

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;
-(NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section;

These methods are optionals, but surely, if you want to display any string either in the section header or in the footer, use them. The UITableViewDataSource protocol is documented here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜