I am using RestKit to pull a news feed and it works for pulling the feed. I have used a Master Detail view and it shows multiple feeds in the console but only displays 1 feed in the UITableView (Only 1 cell)
here is my code
#interface MasterViewController (){
NSArray *feedObjects;
NSMutableArray *feedArray;
}
#property NSMutableArray *objects;
#end
#implementation MasterViewController
- (void)awakeFromNib {
[super awakeFromNib];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
self.clearsSelectionOnViewWillAppear = NO;
self.preferredContentSize = CGSizeMake(320.0, 600.0);
}
}
- (void)viewDidLoad {
[super viewDidLoad];
feedArray = [[NSMutableArray alloc]init];
[self configureRestKit];
// Do any additional setup after loading the view, typically from a nib.
self.navigationItem.leftBarButtonItem = self.editButtonItem;
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:#selector(insertNewObject:)];
self.navigationItem.rightBarButtonItem = addButton;
self.detailViewController = (DetailViewController *)[[self.splitViewController.viewControllers lastObject] topViewController];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(RKResponseDescriptor *)responseDescriptor {
RKObjectMapping *bodyMapping = [RKObjectMapping mappingForClass:[BaseClass class]];
[bodyMapping addAttributeMappingsFromArray:#[#"body",#"title"]];
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:bodyMapping method:RKRequestMethodAny pathPattern:nil keyPath:nil statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
return responseDescriptor;
}
-(void)configureRestKit{
NSURL *baseURL = [NSURL URLWithString:#"http://urlExample"];
NSURLRequest *request = [NSURLRequest requestWithURL:baseURL];
RKObjectRequestOperation *objectRequestOperation = [[RKObjectRequestOperation alloc] initWithRequest:request responseDescriptors:#[[self responseDescriptor]]];
[objectRequestOperation setCompletionBlockWithSuccess:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
feedObjects = mappingResult.array;
[feedArray addObject:feedObjects];
[self.tableView reloadData];
RKLogInfo(#"Load collection of Feeds: %#", mappingResult.array);
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
RKLogError(#"Operation failed with error: %#", error);
}];
[objectRequestOperation start];
}
#pragma mark - Table View
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return feedArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"Cell" forIndexPath:indexPath];
NSMutableArray *feedarray = feedArray[indexPath.row];
BaseClass *feedO = feedarray[0];
cell.textLabel.text = [NSString stringWithFormat:#"%#",feedO.title];
return cell;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the specified item to be editable.
return YES;
}
}
If anyone could help me that would be great, i've tried adding the mappingResults to a NSArray instead of NSMutableArray but this breaks the program the way i have tried.
Thanks
Of course it does - you are adding only one object to your array here:
[feedArray addObject:feedObjects];
Which means that your function returning number of rows:
feedArray.count == 1
What you want to do is to add all results separately to your NSMutableArray or even use NSArray you got from response directly as data source - so you have an NSArray with only 1 depth level.
[feedArray addObjectsFromArray:feedObjects]
Actually in your case I don't see a reason to keep both feedObjects and feedArray, you can throw away feedArray and use feedObjects instead everywhere.
Related
I am able to navigate to the table view But my table is not showing any data neither it is showing error, I want to save my data to core data and want to display it to the table view but it is not showing anything.
Here is some code snippet of my application -
On clicking of save button -
- (IBAction)saveDataButton:(id)sender {
NSManagedObjectContext *context = [self manageobjectcontext];
// NSManagedObject *newemployee = [NSEntityDescription insertNewObjectForEntityForName:#"Employee" inManagedObjectContext:context];
if (self.employeeDB) {
[self.employeeDB setValue:self.empName.text forKey:#"name"];
[self.employeeDB setValue:self.empEmail.text forKey:#"email"];
[self.employeeDB setValue:self.empDesignation.text forKey:#"designation"];
// [self.employeeDB setValue:self.uploadImage.imageView forKey:#"image"];
}
else{
NSManagedObject *newemployee = [NSEntityDescription insertNewObjectForEntityForName:#"Employee" inManagedObjectContext:context];
[newemployee setValue:self.empName.text forKey:#"name"];
[newemployee setValue:self.empEmail.text forKey:#"email"];
[newemployee setValue:self.empDesignation.text forKey:#"designation"];
}
NSError *error = nil;
if (![context save:&error])
{
NSLog(#"Cant save %# %#",error,[error localizedDescription]);
}
UIViewController *objOfView = [[UIViewController alloc]initWithNibName:#"SecondViewController" bundle:nil];
[self.navigationController pushViewController:objOfView animated:YES];
}
Here is my second view controller code for displaying data into the table view -
-(NSManagedObjectContext *)manageobjectcontext{
NSManagedObjectContext *context = nil;
_delegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
if ([_delegate respondsToSelector:#selector(persistentContainer)]) {
context = _delegate.persistentContainer.viewContext;
}
return context;
}
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
NSManagedObjectContext *manageobjectcontext = [self manageobjectcontext];
NSFetchRequest *fetchrequest = [[NSFetchRequest alloc]initWithEntityName:#"Employee"];
self.employeeArray = [[manageobjectcontext executeFetchRequest:fetchrequest error:nil]mutableCopy];
[self.emplyoyeeTableView reloadData];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.employeeArray.count;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"cell" forIndexPath:indexPath];
NSManagedObject *emp = [self.employeeArray objectAtIndex:indexPath.row];
[cell.textLabel setText:[NSString stringWithFormat:#"%#",[emp valueForKey:#"name"]]];
[cell.detailTextLabel setText:[NSString stringWithFormat:#"%#",[emp valueForKey:#"email"]]];
[cell.detailTextLabel setText:[NSString stringWithFormat:#"%#",[emp valueForKey:#"designation"]]];
// [cell.imageView setImage:[emp valueForKey:#"image"]];
return cell;
}
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return YES;
}
`- (void)viewDidLoad
{
[super viewDidLoad];
self.employeeArray=[[NSMutableArray alloc] init]; //do this step
// Do any additional setup after loading the view.
}`
Seems like you are not implemeting and setting your tableview delegates properly. Try
#interface YourClass ()<UITableViewDelegate, UITableViewDataSource> {
- (void)viewDidLoad {
[super viewDidLoad];
self.employeeArray=[[NSMutableArray alloc] init]; //do this
tableView.dataSource = self
tableview.delegate = self
// Do any additional setup after loading the view.
}
}
I am attempting to load data into a UITableViewCell whenever the refresh control is activated. My code successfully retrieves the data and I can verify this with NSLog, but the ViewCell does not update with the new data when Refresh Control ends. Can anyone point me in the right direction?
Below is MyViewController.m file:
#define JSON_URL #"https://website.com"
#import "MyViewController.h"
#import "Object.h"
#import "MyViewCell.h"
#interface MyViewController ()
#property (nonatomic,strong) NSMutableArray *objectHolderArray;
#end
#implementation MyViewController
- (void)viewDidLoad
{
NSURL *blogURL = [NSURL URLWithString:JSON_URL];
NSData *jsonData = [NSData dataWithContentsOfURL:blogURL];
NSError *error = nil;
NSDictionary *dataDictionary = [NSJSONSerialization
JSONObjectWithData:jsonData options:0 error:&error];
for (NSDictionary *bpDictionary in dataDictionary) {
Object *currenHotel = [[Object alloc]Station:[bpDictionary objectForKey:#"station"] Status:[bpDictionary objectForKey:#"status"]];
[self.objectHolderArray addObject:currenHotel];
}
[super viewDidLoad];
//to add the UIRefreshControl to UIView
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:#"Please Wait..."]; //to give the attributedTitle
[refreshControl addTarget:self action:#selector(refresh:) forControlEvents:UIControlEventValueChanged];
}
- (IBAction)refresh:(UIRefreshControl *)sender {
[self viewDidLoad];
[sender endRefreshing];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:
(NSInteger)section
{
return [self.objectHolderArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
MartaViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier
forIndexPath:indexPath];
Object *currentHotel = [self.objectHolderArray
objectAtIndex:indexPath.row];
cell.lblStation.text = currentHotel.station;
cell.lblStatus.text = currentHotel.status;
return cell;
}
-(NSMutableArray *)objectHolderArray{
if(!_objectHolderArray) _objectHolderArray = [[NSMutableArray alloc]init];
return _objectHolderArray;
}
#end
You need to reload your data. Implement Refreshcontroll like this:
- (void)viewDidLoad {
refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self
action:#selector(update)
forControlEvents:UIControlEventValueChanged];
[self.startScreenView addSubview:refreshControl];
}
- (void) update {
[refreshControl beginRefreshing];
[yourTableView reloadData];
[refreshControl endRefreshing];
}
You do not actually modify, nor reload the table view and its data in any way in the refresh function. You should update the data source of your table view and then call [tableView reloadData]; after the update.
In my case i have two views in tab bar controller (categories and Home), one with collection view and one with table view.
In the table view, It starts to load data when only user taps(Home) on its tab bar item.I want to load data , when app launch. I am using AFNetworking, and I have called to my data loading method in viewDidLoad. same thing happen with collection view.please help me with this.hope your help thank you. I have attached part of my code, which I used to load data to table view.
- (void)viewDidLoad {
[super viewDidLoad];
[self.view addSubview:self.homeTableView];
// [self homeviewData];
SWRevealViewController *revealController = self.revealViewController;
if (revealController) {
[self.sidebarButton setTarget:self.revealViewController];
[self.sidebarButton setAction:#selector(revealToggle:)];
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
}
// Do any additional setup after loading the view.
}
- (void)viewWillAppear:(BOOL)animated
{
[self homeTableView];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)homeviewData
{
homepost = nil;
NSString *mogohomeWebserviceUrl = [NSString stringWithFormat:#"some url"];
AFHTTPRequestOperationManager *homeManager = [AFHTTPRequestOperationManager manager];
[homeManager GET:mogohomeWebserviceUrl parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
homeposts = (NSDictionary *)responseObject;
homepost = [NSMutableArray array];
NSArray *results = [homeposts objectForKey:#"posts"];
for (NSDictionary *all in results)
{
Home *sweetHome = [Home new];
sweetHome.homeImage = [NSString stringWithFormat:#"%#", [all objectForKey:#"thumbnail"]];
sweetHome.homeTitle = [NSString stringWithFormat:#"%#", [all objectForKey:#"title"]];
sweetHome.homewebUrl = [NSString stringWithFormat:#"%#", [all objectForKey:#"url"]];
sweetHome.modifiedTime = [NSString stringWithFormat:#"%#", [all objectForKey:#"modified"]];
[homepost addObject:sweetHome];
[self.homeTableView reloadData];
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [homepost count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
HomeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"homereuseIdentifier"];
Home *mogoHome = [homepost objectAtIndex:indexPath.row];
NSString *homeimageurlname = [NSString stringWithFormat:#"%#", mogoHome.homeImage];
NSURL *homeimageurl = [NSURL URLWithString:homeimageurlname];
cell.hometitleLabel.text = mogoHome.homeTitle;
[cell.homeimageView setImageWithURL:homeimageurl placeholderImage:nil];
cell.timeLabel.text = [[mogoHome.modifiedTime componentsSeparatedByString:#" "] objectAtIndex:1];
return cell;
}
You got to understand that the data will only be loaded and displayed after the API request to fetch the data is completed...
This implies you should either be ready with data before the screen appears. This is possible only if the data is independent of user action or Master Data, and you can fetch it right at App Launch. If user action is responsible for the fetched data, you have no option but to wait, and show an Activity Indicator. If you decide to do this, you will find a relevant answers how to do that..
All the best...
EDIT: By "function" I am referring to the (UITableView)tableView cellForRowAtIndexPath, it's stated in my title but I wanted to make it clear
So, yes, there are other answers I have a couple 1stexample, 2ndexample . My function is not being called for some reason. I was following this tutorial. Went back 5 different times to make sure I did all the datasource and delegates right, I think I am. I have done iOS apps before and never had an issue with this. I don't think anything is wrong with the code, I debugged it and it should be working fine. I'll post it anyways just in case I am making an amateur mistake somewhere in there. Don't think I am, but I've been wrong before.
ViewController.h
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
#property (weak, nonatomic) IBOutlet UITableView *tableView;
#end
ViewController.m
#interface ViewController ()
#property (strong, nonatomic) NSArray *array;
#end
#implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self twitterTimeline];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark Table View Data Source Methods
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [_array count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellID = #"cellID";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if(cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
}
NSDictionary *tweet = _array[indexPath.row];
cell.textLabel.text = tweet[#"text"];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
-(void)twitterTimeline
{
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[account requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error){
if(granted == YES)
{
NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];
if([arrayOfAccounts count] > 0) {
ACAccount *twitterAccount = [arrayOfAccounts lastObject]; //grabs last account that is on iPhone, perhaps we would have the user make a selection of which user but for this beginning its fine
NSURL *requestAPI = [NSURL URLWithString:#"http://api.tiwtter.com/1.1/statuses/user_timeline.json"];
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
[parameters setObject:#"100"
forKey:#"count"];
[parameters setObject:#"1" forKey:#"include_entities"];
SLRequest *posts = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:requestAPI parameters:parameters];
posts.account = twitterAccount;
[posts performRequestWithHandler:^(NSData *response, NSHTTPURLResponse *urlResponse, NSError *error) {
self.array = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];
if(self.array.count != 0) {
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
}
}];
}
} else {
NSLog(#"%#", [error localizedDescription]);
}
}];
}
#end
Here's my referencing outlets (which is why I think it's really weird it's not calling the function). ScreenshotLink. Sorry I guess I need 10 rep to post pictures directly on SO.
I very much appreciate any help given.
Why don't you put a breakpoint on [self.tableView reloadData];. If your breakpoint never gets hit then your array is empty. You should also check the error value if it has anything useful in it.
I would put a NSLog in the
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(#"array count is %d", [_array count]);
return [_array count];
}
I think it's empty and will therefore not call the other methods.
While I was surfing over the Internet I've found a lot of examples how to load array in the TableViewController, but none of them helped me!
Couldn't you help me to find what is wrong in my code ?
Thank you in advance!!!
#import "Images.h"
#import "AFNetworking.h"
#import "HTMLparser.h"
#interface Images ()
#end
#implementation Images
#synthesize data;
#synthesize textFromVC1;
#synthesize tableView;
#synthesize so2;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.data = [[NSMutableArray alloc]init];
NSError *error = nil;
NSString *so = [#"http://" stringByAppendingString: self.textFromVC1];
NSURL *url = [[NSURL alloc]initWithString:so];
NSString *str=[[NSString alloc] initWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
HTMLParser *parser = [[HTMLParser alloc] initWithString:str error:&error];
if (error) {
NSLog(#"Error: %#", error);
[parser release];
parser = nil;
return;
}
HTMLNode * body = [parser body];
NSArray *inputs = [body findChildTags:#"img"];
for (HTMLNode *input in inputs) {
NSString *links = [input getAttributeNamed:#"src"];
NSString *so1 = [so stringByAppendingString: #"/"];
so2 = [so1 stringByAppendingString: links];
[self.data addObject:so2];
NSLog(#"%#", data);
NSURLRequest *request = [[NSURLRequest alloc]initWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON)
{
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON)
{
}];
[operation start];
}
[self.tableView reloadData];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (void)viewDidUnload
{
[self setTableView:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
// Return the number of sections.
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.data.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellID = #"LinkID";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
}
cell.textLabel.text = [self.data objectAtIndex:indexPath.row];
[self.tableView reloadData];
return cell;
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/
/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:#[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/
/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
/*
<#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:#"<#Nib name#>" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
*/
}
- (void)dealloc {
[tableView release];
[super dealloc];
}
#end
well 1) numberOfSections is 0. to see something it should be one IIRC
think thats it but havent double checked
Assuming your data array is built up correctly, your mistake in is your numberOfSections methods. Currently, it returns 0, which tells the UITableView that there are currently no sections to be displayed… ever.
You can either return 1; there or remove the entire method altogether. The default implementation, which you inherit from UITableViewController, also returns 1 by default.
My advice would be to remove the method, as that keeps your own code cleaner. You can always implement it in a later stage, when you might actually need it.