1

アプリケーションで sqlite データベースを使用します。私のsqliteには10個のレコードが存在します。このデータベースから 4 つのデータを読み取り、最後のデータの BroID が NULL になるまでこのデータを取得したい (BroID は列データの 1 つです) これは私のコードですが、BroID になるまでコードでループを使用する方法がわかりませんヌル。

    -(NSMutableArray *)readInformationFromDatabase
    {
        array = [[NSMutableArray alloc] init];

        // Setup the database object
        sqlite3 *database;
        // Open the database from the users filessytem
        if(sqlite3_open([[self dataFilePath] UTF8String], &database) == SQLITE_OK)
        {
// I want to use loop for certain work!!! (this work is get name from data base until BroID to be NULL )
            NSString *sqlStatement_userInfo =[NSString stringWithFormat:@"Select * from table1"];
                sqlite3_stmt *compiledStatement;
                if(sqlite3_prepare_v2(database, [sqlStatement_userInfo UTF8String], -1, &compiledStatement, NULL) == SQLITE_OK)
                {
                    // Loop through the results and add them to the feeds array
                    while(sqlite3_step(compiledStatement) == SQLITE_ROW)
                    {
                        // Init the Data Dictionary
                        NSMutableDictionary *_dataDictionary=[[NSMutableDictionary alloc] init];
                        NSString *_userName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)];
                        [_dataDictionary setObject:[NSString stringWithFormat:@"%@",_userName] forKey:@"Name"];

                        [array addObject:_dataDictionary];
                    }
                }
                else
                {
                    NSLog(@"No Data Found");
                }

このコードを実行する方法を教えてください。

4

1 に答える 1