循环通过while(sqlite3_step(语句)直到所有行

时间:2015-07-15 09:43:15

标签: ios objective-c sqlite

我在我的iOS应用程序中将多个值存储在Sqlite数据库中。

我需要检索“cellForRowAtIndexPath”

下的值
int main()
{
    int a = 10;
    int b = 34;
    int c = a + b;
    return c;
}

从这段代码中,我需要在test@test-desktop:~/Desktop/c$ ls -l total 4 -rw-rw-r-- 1 test test 68 Jul 15 15:04 simple.c test@test-desktop:~/Desktop/c$ gcc simple.c test@test-desktop:~/Desktop/c$ ls -l total 12 -rwxrwxr-x 1 test test 7151 Jul 15 15:04 a.out -rw-rw-r-- 1 test test 68 Jul 15 15:04 simple.c

处循环

当我在- (NSString *) retrieveDetailText :(NSString *) emailAddress :(NSString *) uidText :(NSString *) folderName { NSString *detailText = nil; const char *dbpath = [databasePath UTF8String]; //SQLIte Statement NSString *selettablequery = [NSString stringWithFormat:@"select * from MailFolderDBTable"]; if (sqlite3_open(dbpath, &database) == SQLITE_OK) { if (sqlite3_prepare(database, [selettablequery UTF8String], -1, &statement, NULL) ==SQLITE_OK) { while(sqlite3_step(statement) == SQLITE_ROW) { char *uidfield = (char *) sqlite3_column_text(statement, 5); NSString *uidStr = [[NSString alloc] initWithUTF8String: uidfield]; NSLog(@"retrieveDetailText: uidStr: %@", uidStr); if([uidStr isEqualToString:uidText]) { char *emailstring = (char *) sqlite3_column_text(statement, 6); NSString *detailTextData = [[NSString alloc] initWithUTF8String: emailstring]; NSData *data = [[NSData alloc] initWithBase64EncodedString:detailTextData options:NSDataBase64DecodingIgnoreUnknownCharacters]; detailText = [NSKeyedUnarchiver unarchiveObjectWithData:data]; } 下呼叫while(sqlite3_step(statement) == SQLITE_ROW)时,它未在retrieveDetailText循环播放,它只检查cellForRowAtIndexPath一次。

如何遍历while(sqlite3_step(statement) == SQLITE_ROW),直到检查完所有行并获取值。

0 个答案:

没有答案