I'm developing an iOS 4 application and I have developed some classes that I want to use in others projects.
One of this classes, called MapViewController
, is a UIViewController subclass. This class uses a XIB file that I've created with interface builder.
I'm wondering if a use MapViewController
in another project as a super class from a new class, How can I use it associated XIB?
I want to reuse MapViewController
and its XIB, but I don't know if I have to do something special with the XIB file.
I don't know how to explain this. If you need more details, please tell me.
UPDATE:
I want to create a new class that inherit from MapViewController
, like this:
...
@interface NewMapViewController : MapViewController {
...
And, now if I want to continue using the same XIB (the one from MapViewController
), what must I do?
Since you are gonna inherit from MapViewController
, your MapViewController
becomes the super class. And you also have MapViewController.xib. It seems pretty straightforward to me if you use the initializer for NewMapViewController
NewMapViewController.m
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
NSLog(@"Subclass initWithNibName called");
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
Initialize your NewMapViewContoller like:
//Nib of super class is MapViewController
NewMapViewController *nmapController = [[NewMapViewController alloc] initWithNibName:@"MapViewController" bundle:[NSBundle mainBundle]];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With