So, I develop the app that uses sqlite3 database methods. I have several view controllers so I decided to create a separate class for database methods. I called it DataBaseController.
When I try to load it in my app delegate and view controllers like this:
@class DataBaseController;
@interface FirstViewController : UIViewController {
DataBaseController *dataBaseController;
}
@property (nonatomic, retain) DataBaseController *dataBaseController;
@end
and then I implement it in FirstViewController.m. But when I try to call in AppDelegate, FirstViewController.m and other controllers the methods I implemented in DataBaseController, for example like:
#import "DataBaseController.h"
...
@synthesize dataBaseController;
...
-(void)ViewDidLoad {
[self.dataBaseController openDB];
[self.dataBaseController getRowsFromTable];
[super ViewDidLoad];
}
it works only in AppDelegate.
Please, suggest me any ideas on my problem. Thanks in advance.
I think you have to initialize the object.
Your DataBaseController has an function called init right? Thats also a good place to open your database file.
Than do:
dont forget to set your object to nill in your dealloc / viewdidunload if you make create a property.
Hope this helps you out.
Rolf