我正在使用FMDB。我創建並插入到表中。它工作正常。使用FMDB無法讀取數據
IDX INTEGER NOT NULL DEFAULT 0 PRIMARY KEY AUTOINCREMENT
topicId VARCHAR NOT NULL
listChat BLOB NOT NULL
但我不能得到所有數據從listChat列表。這裏是我的代碼:
- (NSMutableArray*)readChatHistoryFromDatabaseWithTopicId:(NSString *)topicId {
NSMutableArray *listChat = [[NSMutableArray alloc] init];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *path = [self databasePath];
if ([fileManager fileExistsAtPath:path] == YES) {
FMDatabase *database = [FMDatabase databaseWithPath:path];
if (database) {
[database open];
NSString *query = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE topicId=\"%@\"", OCSDK_CHAT_HISTORY_TABLE_NAME, topicId];
FMResultSet *results = [database executeQuery:query];
[results next];
NSData *notesData = [results dataForColumn:@"listChat"];
[listChat addObject:notesData];
NSLog(@"notes: %@", listChat);
}
[database close];
}
return listChat;
}
它打印:
什麼是錯我的代碼?