views:

6667

answers:

1

i have a uitableviewcontroller here is the .h file code

@interface addToFavourites : UITableViewController {

}

@end

and here is the .m file code

#import "addToFavourites.h"


@implementation addToFavourites

- (id)initWithStyle:(UITableViewStyle)style {
    if (self = [super initWithStyle:style]) {
    }
    return self;
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 5;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *MyIdentifier = @"MyIdentifier";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
    if (cell == nil) {
     cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
    }
    // Configure the cell

    return cell;
}

@end

and in another class i am showing this view using this code

addToFavouritesobj = [[addToFavourites alloc] initWithStyle:UITableViewStylePlain]; [self.navigationController pushViewController:addToFavouritesobj animated:YES];

how do i call reload method of this uitableviewcontroller class?

there is no need of declaring tableview because this view automatically genrating a table

i am very confused how to reload the table?

+4  A: 

addToFavouritesobj.tableView will give you access to the UITableView object.

[addToFavouritesobj.tableView reloadData]


BTW: class names should start with capital letter. A better name for your class would be AddToFavouritesController.

porneL
Is reloadData a method implemented elsewhere?
Picflight
reloadData is a method of UITableView, so it's available everywhere where you can get to that object.
porneL