配列が0のカウントを返しているので、私はこれを正しく行っていますか?
-(NSArray *)getAllFavourites{
NSMutableArray *arrFavourites = [[NSMutableArray alloc] init];
NSString *query = @"SELECT * FROM tbl_favourites;";
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(database, [query UTF8String], -1, &statement, nil) == SQLITE_OK){
while (sqlite3_step(statement) == SQLITE_ROW ){
char *charSymbols = (char *) sqlite3_column_text(statement, 0);
NSString *strFetchedSymbol = [[NSString alloc] initWithUTF8String:charSymbols];
DBClassFavourites *dbClassFav = [[DBClassFavourites alloc] initWithString:strFetchedSymbol];
[arrFavourites addObject:dbClassFav];
}
sqlite3_finalize(statement);
}
NSLog(@"%i",[arrFavourites count]);
return arrFavourites;
}
必要な変数を初期化するこのクラスもあります。
@implementation DBClassFavourites
-(id) initWithString:(NSString *)symbol
{
self = [super init];
if (self) {
self.strSymbol = symbol;
}
return self;
}
-(void) dealloc
{
[strSymbol release];
[super dealloc];
}
これは、私のfirstviewcontrollerinit関数からすべてが呼び出される場所です
@implementation FirstViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
arrFavourites = [[DatabaseManager database] getAllFavourites];
}