我是初学者,我创建了名为 MyDatabase 的数据库。我想在标签中显示表格中的一些行,我的代码是,请让我知道解决方案,在此先感谢
@interface ViewController ()
{
MyDatabase *data;
NSMutableArray *tickerarray;
}
@end
@implementation ViewController
-(void)action
{
label.text= @"Phase || possession: Jan 2014";
}
- (void)viewDidLoad
{
[super viewDidLoad];
data=[MyDatabase new];
tickerarray=[data OpenMyDatabase:@"SELECT title FROM news_ticker" :@"title"];
time = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(action) userInfo:nil repeats:NO];
[label setFont:[UIFont fontWithName:@"Arial" size:15]];
label.textColor = [UIColor grayColor];
}
@end
编辑:
-(NSMutableArray *)OpenMyDatabase: (NSString *)query:(NSString *)column {
self.databaseName=@"App_Database.sqlite";
FMDatabase *database=[self openDatabase: self.databaseName];
[database open];
NSArray *nsarr= [self storeDatabaseColumnInArray: database: query:column];
[database close];
}