0

I am creating an app in which there are two UIViews and in those UIViews I am loading Tableviews.. When I click a tablecell in one TableView then I am unable to redirect it to another TableView and getting error:Program received signal SIGABRT.But if I want to load a UIView when a tablecell is clicked it gets executed perfectly.I couldn't understand where Am I going wrong.... This is the code i'm writing

 ViewController1:
   #import ViewController2.h"

     -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

        ViewController2 *v2 = [ViewController alloc] initWithNibName:@"ViewController2" bundle:[NSBundle mainBundle]];
        [self presentModalViewController:v2 animated:NO]; **//getting error at this line**
        [v2 release];

    }
    ViewController2.h
    #import"ViewController1.h"
    - (void)viewDidLoad
    {
    [super viewDidLoad];
   tableView1 = [[UITableView alloc]initWithFrame:CGRectMake(10, 10, 320, 460)];
    tableView1.delegate = self;
    tableView1.dataSource = self;
    [self.view addSubview:tableView1]; 

   }  

Couldn't understand what could be the possible cause of this error..

6
  • Don't call alloc without then calling some form of init... method...whichever one is appropriate for your object. Oct 5, 2012 at 11:25
  • Can u please explain briefly.I couldn't get u
    – Honey
    Oct 5, 2012 at 11:26
  • You are allocating memory for your GetAppointments object but then not initializing it. If you look at any sample code for creating a view controller, it should have something like [[GetAppointments alloc] init<#...some type of initialization...>];. Oct 5, 2012 at 11:29
  • I edited the code but still no luck
    – Honey
    Oct 5, 2012 at 11:37
  • The "code" you have posted wouldn't even compile. (ViewController2 *v2 = [ViewController alloc] initWithNibName:@"ViewController2" bundle:[NSBundle mainBundle]];) I'm not going to make guesses about what might be wrong with something I can't see. Oct 5, 2012 at 11:46

1 Answer 1

1

Maybe this is the bug

    ViewController2 *v2 = [ViewController alloc] initWithNibName:@"ViewController2" bundle:[NSBundle mainBundle]];

You have allocated ViewController instead of ViewController2

Try this and it should work, I guess.

    ViewController2 *v2 = [ViewController2 alloc] initWithNibName:@"ViewController2" bundle:[NSBundle mainBundle]];
1
  • ok, you should also check whether all the IBOutlets are connected properly in the .xib file or not by right clicking the File's Owner.
    – mayuur
    Oct 6, 2012 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.