I have a little problem. Since my UIViewControlles are named in the same way:
MyView1Controller.h MyView1Controller.m MyView1.xib
MyView2Controller.h MyView2Controller.m MyView2.xib
MyView3Controller.h MyView3Controller.m MyView3.xib
Now, I would prefer to initialize my UIViewControllers using the factory method. Therefore, I would execute Cateogry on a UIViewController:
static NSString *standardNibFileName; @interface UIViewController (FactoryInstantiation) + (id) standardViewController; @end
And in MyView1Controller, I would declare a static variable for the nib file name:
static NSString *standardNibFileName = @"MyView1"; @implementation MyView1Controller
Then I could instantiate all of my UIViewCOntrollers using the method:
@implementation UIViewController (FactoryInstantiation) + (id) standardViewController; { if(standardNibFileName != nil) { NSString *className = NSStringFromClass([self class]); Class classToIntantiate = NSClassFromString(className); return [[classToIntantiate alloc] initWithNibName:className bundle:nil]; } return nil; } @end
Init:
MyView1Controller *a = [MyView1Controller standardViewController];
But a static variable is always zero.
Any suggestions for resolving this issue?
I would be grateful for any help!
Thanks in advance.
source share