views:

24

answers:

0

I have an iphone app that uses table view as the interface. Each time that the user taps on one of the table cells, I want to show another window to the user. However the user interface of the window that I push into the navigation controller are extremely similar. Therefore I decided to make a "generic nib file" to be used across all the subclasses of the file owner of this generic nib file.

However what I'm confused (and what's not working) is that I can't seem to be able to customise this generic nib file. I have this code at the initialisation of the files:

In the .h file:

#import <UIKit/UIKit.h>
#import "primeViewController.h"

@interface subclass1 : primeViewController { //subclassing from a generic view controller that owns a generic nib file

}

In the .m file:

#import "subclass1.h"

@implementation subclass1

- (id) initWithLabelAndButton {
    if(self = [super initWithNibName:@"primeViewController" bundle:nil]) {
        self.label.text = @"Title of the first subclass";   

    }
    return self;
}

But then when I instantiate the class in the table view:

//somewhere in rootviewcontroller.m:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    switch (indexPath.row) {
        case 0:
        {
            checkPrime* checkPrimeViewController = [[checkPrime alloc] initWithLabelAndButton];
            [self.navigationController pushViewController:checkPrimeViewController animated:YES];
            [checkPrimeViewController release];
            break;
        }
        default:
            break;
    }
}

So can anyone tell me what I'm doing wrong? Or am I wrong assuming that xcode allow me to use nib file multiple time across its subclasses? I don't see why I can't do it, but I can't figure out how...