0

I have a relatively huge application with about 40 views and about 300 classes. The application uses SQLite database. I develop this app about half a year and till now everything is ok. The process of creating views and controllers at runtime are made by a ViewController Factory. At every start I create a dictionary with info about all viewcontrollers (storing class and xib name as string). Then when I want to display a view, I use the NSClassFromString method to get the controller's class, and I create the controller with the following method:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

The strangest thing is in case of certain viewcontrollers (about 5 of about 40) this method gives back nil (such a viewcontroller too, where I don't fetch data from database, so I don't think this would be the problem). Till now everything is ok, every view controllers created. I noticed that, I can resolve this issue by deleting every IBOutlet reference, and drawing the view from code. Then the method works again. I don't understand that... I tried to create a new view and add all IBOutlet reference again, but it doesn't work. Anyone faced this problem earlier? Thanks, madik

madik
  • 133
  • 2
  • 10

1 Answers1

0

Could be that a class of that name is not currently loaded?

NSClassFromString returns nil

Also see the comment about singleton's preventing classes from loading?

Community
  • 1
  • 1
ader
  • 5,403
  • 1
  • 21
  • 26
  • I logged to debug console each dictionary, which hold the class and XIB name as string, everything ok. The NSClassFromString method works too, it gives back the correct class. Only the viewcontroller doesn't created with the mentioned method... – madik Oct 14 '11 at 14:48