0

I have table in which i would like to tap on the cell and it takes me to another table. I got this error while running in Xcode 4.3.2 :

 return UIApplicationMain(argc, argv, nil, NSStringFromClass([RanchForecastTouchAppDelegate class]));

 Thread 1: Signal SIGABRT

I saw alot of answer related this error in this forum but it didn't work, it's the reason that I asked question again.

My code is: CreateViewController.h

#import <UIKit/UIKit.h>

@interface CreateViewController : UIViewController <
UITableViewDataSource, UITableViewDelegate>
{
NSArray *tableData;

}

@property (nonatomic, retain) NSArray *tableData;
@end

CreateViewController.m

#import "CreateViewController.h"

@implementation CreateViewController
@synthesize tableData;


#pragma mark - View lifecycle

- (void)viewDidLoad
{
tableData = [[NSArray alloc] initWithObjects:@"Johan", @"Paul",@"George",@"Ringo", nil];
[super viewDidLoad];
// Do any additional setup after loading the view.
}

#pragma mark - TableView Data Source methods

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
{
return [tableData count];

}


  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
UITableViewCell *cell = nil;

cell = [tableView dequeueReusableCellWithIdentifier:@"MyCell"];
if(cell == nil)
{
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MyCell"];

}
cell.textLabel.text = [tableData objectAtIndex:indexPath.row];

return cell;
}


 @end

Error message on console:

[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x68ab4d0

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x68ab4d0'

Edit:

#import "RanchForecastTouchViewController.h"

@interface RanchForecastTouchViewController ()

@end

@implementation RanchForecastTouchViewController

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
    return YES;
}
}

 @end

RanchForecastTouchViewController.h

#import <UIKit/UIKit.h>

@interface RanchForecastTouchViewController : UIViewController

@end
Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285

2 Answers2

0

you added semicolons at the end of the line

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

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

just remove them

Chakalaka
  • 2,807
  • 19
  • 26
  • That's unlikely to be the issue - Obj-C allows this. – Jasarien Apr 23 '12 at 10:36
  • @Chakalaka problem again -->> [UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x6854510 –  Apr 23 '12 at 10:39
  • return UIApplicationMain(argc, argv, nil, NSStringFromClass([RanchForecastTouchAppDelegate class])); Thread 1: Signal SIGABRT –  Apr 23 '12 at 10:39
  • do you have more ViewControllers? – Chakalaka Apr 23 '12 at 10:42
  • is RanchForecastTouchViewController a delegate for a tableview? if yes so you need to implement numberOfRowsInSection... too – Chakalaka Apr 23 '12 at 11:32
0

check your user interface connection, It would be for some wrong connections!